Help populating DataGrid

Hello,

At runtime I have a datagrid which has data coming from a dataview which has data coming from a dataset. Is this possible with CF 20 I am not able to see the data within the datagrid at runtime. Am I missing something in my code Thanks in advance.

John

Code:

Private Sub load_datagrid(ByVal dsDataset As DataSet)

Dim dv As New DataView

dv.Table = dsDataset.Tables(0) 'has data

'Dim i As Integer

'For i = 0 To dv.Table.Rows.Count - 1

' MessageBox.Show((dv.Table.Rows(i)("id"))) 'used to verify data exists and does

'Next

Dim dgTable As New DataGridTableStyle

dgTable.MappingName = dv.Table.TableName

Dim dgCol0 As New DataGridTextBoxColumn

dgCol0.MappingName = "id"

dgCol0.HeaderText = "ID"

dgCol0.Width = 5

dgTable.GridColumnStyles.Add(dgCol0)

Dim dgCol1 As New DataGridTextBoxColumn

dgCol1.MappingName = "code"

dgCol1.HeaderText = "Code"

dgCol1.Width = 20

dgCol1.NullText = ""

dgTable.GridColumnStyles.Add(dgCol1)

datagrid1.TableStyles.Clear()

datagrid1.TableStyles.Add(dgTable)

End Sub



Answer this question

Help populating DataGrid

  • LoveCode

    you forgot to set the datagrid1.DataSource property.


  • MIS

    Yes, that is possible. Common mistake is to use wrong case in mapping names. I would also suggest adding TableStyle to the grid before adding column styles to the TableStyle.



  • davidhhhhhhhhhhhhhh

    Thanks guys. I must have been sleeping when forgetting the datasource for the datagrid. I am trying to develop on a wm 5.0 and am wondering if someone could point me to where I can read on the button that changes the screen to landscape. I need to be able to change the layout of the form if the user changes the screen layout. Thanks so far.

    John


  • Help populating DataGrid