Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
735
WinGrid custom column sorting
posted

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?

Thanks,
Zongwen

Parents
  • 69832
    Suggested Answer
    Offline posted

    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.

Reply Children