Sorting datagridview

Set sorting

Sorting in a datagridview is set by column.
You can set it in the designer via Datagridview Properties - Columns - Behavior - Sortmode.
Programmatically via dgv.Columns[x].SortMode = DataGridViewColumnSortMode.Automatic
There are 3 sorting modes: Automatic, NotSortable and Programmatic.
The default is NotSortable.

Programmatic Sorting

You can sort a datagridview programmatically by calling its Sort method.
Sort(DataGridViewColumn, ListSortDirection)

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License