Hi,
Can anyone tell me hoe to work in MSFlexGrid controll. Bcoz i tried to bind the records into that FlexGrid. But when i click in that data property, it shows some intrinsic error.
So can anyone tell me about FlexGrid in detail with some coding?

Hi,
FlexGrid is designed for Data Control (Intrinsic Control) in VB. It cannot be bind with ADODB. You use load the records manually. Also Flex Grid allow the user to modify content. Some techniques (user directly enter the values) need to do . Instead of FlexGrid you can use Data Grid Control.

I Give example to load 3 x 3 Null (0) Matrix into Flex Grid. You can Modify to load the records

Dim iRow As Integer
   Dim iCol As Integer
   
   With MSFlexGrid1
      .Rows = 4      ' Including Fixed Row
      .Cols = 4      ' Including FixedCol
      .FixedCols = 1
      .FixedRows = 1
      
      ' Load Column Names
      For iCol = 1 To 3
         .TextMatrix(0, iCol) = iCol
      Next
      
      ' Load Row Names
      For iRow = 1 To 3
         .TextMatrix(iRow, 0) = iRow
      Next
      
      ' Load the data here 0
      ' Can be used to load the data from recordset
      For iRow = 1 To 3
         For iCol = 1 To 3
            .TextMatrix(iRow, iCol) = 0
         Next
      Next
   End With

Dim db As New ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub Form_Load()
db.CursorLocation = adUseClient
db.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\SampleDB.mdb"

Set rs = db.Execute("SELECT * FROM tbl_Student")
With MSFlexGrid1
.Cols = 2 'Fixed Colunms
.Rows = 1 'Fixed Rows
.TextMatrix(0, 0) = "Idno"
.TextMatrix(0, 1) = "name"
Do Until rs.EOF
'1st colunms '2nd Colunms
.AddItem rs(0) & vbTab & rs(1)
rs.MoveNext
Loop
End With
rs.Close
db.Close
Set rs = Nothing
Set db = Nothing
End Sub

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.