I have a databound boolean column that by default displays as a checkbox. Instead of a checkbox I want this column to display an image when it is true.
I assume the checkbox comes from the Style property of the column which is set to default. So I changed that to Image but I don't know where to go from there.
How do I use an image in a boolean column to represent true?
The fastest way to do this is to use the GlyphInfo property of an UltraCheckEditor and assign that control as the EditorControl of the column. This will allow you to specify images (or lack thereof) for True, False, and Indeterminate. I believe that this property was added in the 2008 Volume 2 release.
If this is not an option, then another alternative is to create an unbound column in the grid and hide your boolean column. In the InitializeRow event, you would set the Image of the cell in the unbound column accordingly.
-Matt
I have a GlyphStyle but not a GlyphInfo.
I supposed we are using an older release.
Is there no way to do this using the ValueBasedAppearance property?
Here's another way to do it:
This makes sense because the grid does not know how to sort an image column, so you would have to implement the IComparer interface, detailed by the following article:
HOWTO:Sorting one WinGrid column by evaluating another column.
I implemented this solution:
'If this is not an option, then another alternative is to create an unbound column in the grid and hide your boolean column. In the InitializeRow event, you would set the Image of the cell in the unbound column accordingly."
It worked but I am unable to sort on the column.
The ValueBasedAppearance property simply adds an extra step in the cell appearance resolution process, but if you have a CheckEditor in the cell, that is not going to be changed by changing the Appearance (i.e. it won't replace the checkbox with an image that you specify).