Browse » Home
Friday, February 17, 2012
How to Use MSFlexGrid in VB6
1. Click the Windows "Start" button and select "All Programs." Click "Microsoft Visual Basic," and then click "Visual Basic 6" to open the compiler.
2. Open the desktop form that contains the MSFlexGrid. If you do not already have an MSFlexGrid control on the form, drag and drop a control from the toolbox.
3. Set the number of rows to the amount of records in your data set. The following code sets up the number of rows equal to the amount of records in the "customers" record set:grid.Rows = customers.RecordCount
grid.Cols = 2
4. Add data to the MSFlexGrid control. For instance, the following code adds the customers record set's first and last name to the two MSFlexGrid's columns:MSFlexGrid.Col[0].Text = customers(0)
MSFlexGrid.Col[1].Text = customers(1)
5. Add the code to loop to the next record. The following code moves the record set to the next record, so you can loop through each row to add to the MSFlexGrid:customers.MoveNext