How to Use MSFlexGrid in VB6
The Visual Basic 6 "MSFlexGrid" control lets you organize data into a spreadsheet to display the data on a Windows desktop form. The MSFlexGrid control does not automatically parse a data set as the GridView control does, so you must manually add records one-by-one in the spreadsheet. To use the grid on your application, you iterate through the data set using a VB6 loop.
Instructions
-
-
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
-
1