Let's say I have to display green button icon for column value "1", yellow for column value "2" and red for "3" . I have two requirements
1. Column shows both value and its associated icon. ie. Column value shows "1" <green button icon>, "2" <yellow button icon>, "3" <red button icon>
2. Columns shows only the icon representing the value
Questions:
a. From reading the forum, valuebasedappearance seems to help me achieve both requirements very easily. Is that correct?
b. How would I achieve sorting of the columns in requirement #1 and requirement #2 ?
a) I don't think so. I think you could acheive option 1 here, but not option 2. The ValueBasedAppearance doesn't give you any good way to hide the text of the cell as far as I know.
It sounds to me like you just need a ValueList on the column and you can assign an Appearance to the ValueListItems on the list.The cell will pick up the appearance of the selected item on the ValueList. The ValueList.DisplayStyle allows you to show just a picture with no text.
b) You don't have to do anything. The column will be sorted by it's displayed text.
Mike Saltzman"]You don't have to do anything. The column will be sorted by it's displayed text
Mike, for the requirement where I have to display only icons, how would I achieve the sorting?
The column will still be sorted by the text that would be displayed - even if it's not actually displayed. You don't have to do anything.
Mike, earlier in the thread I asked about showing icon instead of a value and you suggested using valuelist.
Same status field (with values 1, 2 and 3) but some different requirements. Each item has a status. So, instead of showing status as a separate column, I would like to show it in the same column as Item. So instead of showing
Status Item Number
<icon> Item1
<icon> Item2
I want to show as follows both in the same column, status icon attached to the Item number field. What would such a field sort on? Status or Item Number?
Item Number
<icon>Item1
<icon>Item2
Okay, this really isn't the same thing you described earlier. Or at least it's not what I understood. What I would probably do in a case like this is simply hide the Status column and then use the InitializeRow event of the grid to set the Cell.Appearance.Image on the Number cell to display the appropriate image based on the Status (which is hidden).
In this case, the column would sort based on the Number, not the Status. But if you want to change the sorting behavior of that column, this is easily accomplished using the SortComparer property on the column.