Hi,
I know to sort Datagridview using one column :
$datagridview.Sort($datagridview.Columns[0], 'Ascending')
But I would like to sort a Datagridview using 2 columns.
Data sample:
Status | Name
ON | App1
OFF | App2
OFF | App3
ON | App4
If I sort using first column (Status), second column is not sorted for example :
Status | Name
ON | App1
ON | App4
OFF | App3
OFF | App2
Regards.
Datagridview double sort
Forum rules
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Do not post any licensing information in this forum.
Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
Re: Datagridview double sort
Default column sort can only sort the column chosen. To sort on more than one column set the "RowSort" properties to the rows to be sorted.
Field1 and Field2 are the names of the datatable fields.
See: https://msdn.microsoft.com/en-us/librar ... .110).aspx
- ([System.Data.DataTable]$datagridview1.DataSource).DefaultView.Sort = 'Field1 ASC,Filed2 ASC'
See: https://msdn.microsoft.com/en-us/librar ... .110).aspx