I have a Windows Form DataGridView that I need to apply custom sorting when a particular column header is clicked, and to reverse the sorting when the column header is clicked again.
I will implement my own sorting algorithm, but I am unclear on how to wire or trigger the column header click with an event, and then keeping track of what was the last sort applied to that column so that I can reverse the sort process.
The data for the DataGridView is being provided through a list, and the rows are being added as myList.Rows.Add(string_1, string_2, string_3) to the DataGridView.
Please note that this is not my code, I have just been asked to implement a custom sort for each column.
I have looked online, and have been unsuccessful in finding examples or explanation.
Can anyone provide me with sample code, or point me to a good site that shows a clear example of how to implement this.
Thanks in advance,
Marwan