Hi,
I have an image column in a WinGrid where i show an X image for rejected and tick image for accepted rows. However since these are image columns it does not by default sort. I want to make this column sort on the basis of the column image. Please suggest possible ways to achieve this.
Cheers,
SK
You would have to assign a custom IComparer implementation to the column's SortComparer property. It is not a very intimidating interface (there is only one method to implement); what you could do is use whatever criteria you are using to decide which image to display, and return 1 for one of those conditions and -1 for the other, depending on which rows you want to be closest to the top.
I would really appreciate some code samples. How ever in the mean time i was trying to sort the column whose values are used to set the image column values. i.e. I have a text column whose cell valuses are used to set the image value for the image column. What i was trying to do is when user clicks on the Image column header sort by the text column and set the sortindicator for the image column to None in the before sort event. But i am just not able to find out the column user clicked. Is there any Headerclick event or is there a way to find out which column was intended to be sorted by user click?
Trying to change the column which is being sorting will be very difficult and I would advise against it. This should help make things easier.
HOWTO:Sorting one WinGrid column by evaluating another column.
Mike, so we have a DataColumn with a integer value that has three possible values 0, 1 and 2
1 and 2 are problem states and need to be rendered as two icons say yellow and red dots.
0 would show nothing
This column needs to be sortable. That way all rows with problem states can show together.
Question 1:
The KB article you referenced
Mike Saltzman"] HOWTO:Sorting one WinGrid column by evaluating another column.
is easy to implement but concerns me because it would references Cell so many times. In the performance related thread you said
Mike Saltzman"] The grid does not create UltraGridCell objects for every row of data. Cells are only created as neccessary. So whenever possible, you should avoid accessed a cell.
The grid does not create UltraGridCell objects for every row of data. Cells are only created as neccessary. So whenever possible, you should avoid accessed a cell.
Would you suggest implementing the KB suggested solution differently to avoid the Cell references?
Question 2
To have a sortable column with images, is the only option to do what the KB article suggests? or there are alternatives involving use of ValueList or ValueListApperance etc?
Thanks!