Reputation: 3102
How to allow sorting rows in the DataGridView by clicking on the Column Header.
Upvotes: 1
Views: 10556
Reputation: 507
This is an MSDN link that describes the DataGridViewColumn's SortMode property.
But the DataGridView can't sort any collection automatically (like List
). If you want to support sorting and searching on the collection, you have to derive a class from BindingList
and override a few base class methods and properties.
Upvotes: 2
Reputation: 1
Private Sub GridSupplierHelp_ColumnHeaderMouseClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles GridSupplierHelp.ColumnHeaderMouseClick
GridSupplierHelp.Columns(e.ColumnIndex).SortMode = DataGridViewColumnSortMode.Automatic
End Sub
Upvotes: -1
Reputation: 101
You Could use this in each columns or specified columns to sort the rowsthis->dataGridView1->Columns[n]->SortMode = DataGridViewColumnSortMode::Automatic;
Upvotes: 3