Home - Forums-.NET - FlyGrid.Net (Windows Forms) - Binding to a DataTable

FlyGrid.Net (Windows Forms)

.NET Datagrid - Fast, highly customizable, industry standards .NET data grid control for WinForms

This forum related to following products: FlyGrid.Net

Binding to a DataTable
Link Posted: 30-Aug-2005 08:32
I'm trying to bind a flygrid to a datatable in VB and I get this string "System.Data.DataRowView" in every cell.  What is the proper way to bind a datatable?
My datatable is called SelectedCarriers:

      Grid1.BeginInit()
      Try
         Grid1.Rows.DataSource = SelectedCarriers
      Finally
        Grid1.EndInit()
      End Try
Link Posted: 30-Aug-2005 10:16
Because you forget to add columns.
Did you you see Fastest Data Binding VB.Net sample?

[VB.Net]
Private Sub ConnectToDataTableAndPrepareColumns(ByVal flyGrid As FlyGrid, ByVal dataTable As DataTable)
   flyGrid.BeginInit()
   Try
    Dim i as Integer
    'Add columns
    For i = 0 To dataTable.Columns.Count - 1
      Dim dc As DataColumn = dataTable.Columns(i)
      Dim col As Column = new Column(dc.Caption, dc.ColumnName)
      ' add new column
      flyGrid.Columns.Items.Add(col)
    Next i
    ' connect to a data table
   flyGrid.Rows.DataSource = dataTable
  Finally
    flyGrid.EndInit()
  End Try