Hi, I have a grid with custom column comparer class for each column to do custom sorting. Right now, I can do one column sorting, or multiple column sorting by holding shift key and select multiple columns. However, we want to always add the first column for sort. User wants to just click one of the other column to perform two columns sorting without holding the shift key. In other word, we want to add the first column to sorting columns as the first sort no matter which column user clicks.
One possible way to do that, I think, is to disable the column click sorting on column header, catch the header click event, then programatically add the first column and the column user click to sorted column list.
Is there any easy way to do that?
Your custom comparer can take any criteria into consideration, so all you have to do is factor in the value of the cell in the first column. The Compare method gets passed two cells (one from each of the rows being compared), so you can get a reference to the row off each cell and get the value of the first column cell in each row and make that your primary sort criteria.
thanks for your reply. However, the problem is that we have to make the change to every comparer class and those comparer classes are also shared with other places which doesn't not need this extra logic. I am wondering whether WinGrid is capable of locking the first sort always such that no matter what column header user click, the first column is always fixed and the grid will just add whatever user clicks to the second column and so forth.
thanks,
zongwen