0

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?

3
Contributors
2
Replies
4
Views
9 Years
Discussion Span
Last Post by eanastacio20
0

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
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.