Posted 16 May 2018, 7:59 pm EST
Thanks I was using public fields rather than properties, so the columns weren’t loading.
I’m not sure if there’s a preferred way to load into a grid with existing columns, but I wrote a VB function for that:
Public Sub LoadFlexGrid(ByVal grid As C1FlexGrid, ByVal list As IEnumerable, Optional useExistingColumns As Boolean = True)
Dim initProps As Boolean
Dim colProps() As System.Reflection.PropertyInfo
Dim curRow As Row
If grid Is Nothing Or list Is Nothing Then
Exit Sub
End If
If Not useExistingColumns Then
grid.DataSource = list
Exit Sub
End If
grid.Redraw = False
grid.Rows.Count = 1
For Each item In list
If Not initProps Then
ReDim colProps(0 To grid.Cols.Count - 1)
For j = 0 To grid.Cols.Count - 1
colProps(j) = item.GetType.GetProperty(grid.Cols(j).Name, System.Reflection.BindingFlags.Public Or System.Reflection.BindingFlags.Instance Or System.Reflection.BindingFlags.IgnoreCase)
Next
initProps = True
End If
curRow = grid.Rows.Add
For j = 0 To grid.Cols.Count - 1
If colProps(j) IsNot Nothing Then
curRow(j) = colProps(j).GetValue(item)
End If
Next
Next
grid.Redraw = True
End Sub