sort datagridview IBindingList-Objekt

  • Thread starter Thread starter michaelberg
  • Start date Start date
M

michaelberg

Hi,

I try to sort a datagridview programmaticly.
To do this i bind the Datagridview to a Datatable. Than i read the
last Configuration from a XML file and add the columns with this
configuration.

But every time I try to sort the column, following error is given:
Das DataGridView-Steuerelement muss an ein IBindingList-Objekt
gebunden sein, um sortiert zu werden.
But I think the datatable is a IBindingList Object.

Please help.

....
Me.DataSource = pdataset.Tables(0)
....
For Each drv As DataRowView In dv
Dim i As Integer = Me.Columns.Add(drv("ColumnIdentifier"),
drv("ColumnIdentifier"))
Me.Columns(i).DataPropertyName = drv("ColumnIdentifier")
If Not drv("ColumnWidth").GetType Is GetType(DBNull) Then
Me.Columns(i).Width = drv("ColumnWidth")
Else
Me.Columns(i).Width = 100
End If
If Not dr_sort Is Nothing Then
If drv("ColumnIdentifier") = dr_sort("ColumnValue")
Then
If Not dr_order Is Nothing Then
Me.Sort(Me.Columns(i),
System.ComponentModel.ListSortDirection.Ascending)
Else
Me.Sort(Me.Columns(i), 0)
End If
End If
End If
Next
....
 
thanks for the answer Sheng Jiang

i used the defaultdataview insteat of the datatable... but the error
is continued.
a msgbox(Me.Datasource.gettype.tostring) shows that a datasource is a
dataview.
why is the dataview not a ibindinglist object.
 
Back
Top