I'm using a grid bound to a data set that I'm populating with CellDataRequested. That's allowing me to so some "calculated" fields....one of these fields is a Boolean.
For this boolean, I would like to show an image instead of standard checkbox. i had it working correctly by using an image in the datasource, but now I need to "filter" it, so I switched back to a boolean to get the filter working.
whew...
All i want it to show an image in place of a bool in the grid and was able to allow filtering on those images. (they are just boolean, underneath it all)
what's the easiest way to go.
Gene
Hi Gene,
What version of the grid are you using?
Does the cell need to be editable like a checkbox? Or do you just want to show an image and not allow the user to edit?
Hey Mike,
I'm using Version 8.1. I just want to show one of 2 images and be able to filter based on that image. no editing, just displaying and filtering.
I took a look at this and it appears that it's much more difficult than I thought.
Setting the Style of the Column to TriStateCheckBox worked for me. Although, this allows the user to select the indeterminate state for the entire column, not just the filter cell. So that's probably not what you want.
There doesn't appear to be any easy way to get the filter cell to show a tri-state checkbox and have the cells only use 2 states. It's possible that this could be done using an editor and imlementing a DefaultOwner class, but that's a lot more work than really should be neccessary to do this, in my opinion.
I think it will help if you set the column's FilterOperandStyle to UseColumnEditor so that the filter cell uses the same editor as the cells. That should handle the text showing up and the dropdown arrow.
Thanks Mike,
I now have the filter cell tied to the UltraCheckEditor, but I can't set it to be a 3 state. it just toggles between true and false.
I've tried the following things and haven't had any success.
1. changing the style of the column to be tristatecheckbox
2. picking up the click event and force it to indeterminate
3. picking up the BeforeCheckStateChanged event and forcing it to indeterminate
I'm assuming that I need to change the UltraCheckEditor to be 3 state but I can't find the setting for it.
Is there something better that explains HOW all this stuff works? the library is SOOO big with so many settings, it's hard for me to find anything.
Can you point me to how to set the UltraCheckEditor to be a 3 state so my bound filter cell will rotate thru all 3 states?
thanks again mike,
What I would probably do is set up the filter cell to use the same editor as the column. That way there will be no dropdown. The Filter cell will just be a checkbox using the same images that your column is using. You will probably want to set an IndeterminateAppearace on the UltraCheckEditor to control what the filter cell displays when there is no filtering.
Thanks Mike.
I've got the grid showing the correct image, and the filter dropdown showing the images.
Now that I've got the dropdown filter list showing correctly, I needed to show the filter image in the FilterCell so I did this:
if (e.Column.Key == "Source") { // this will return True, false, and nonblank string s = e.NewColumnFilter.FilterConditions[0].CompareValue.ToString().ToLower(); switch (s) { case "true": e.Column.FilterCellAppearance.Image = ilGridImages.Images[0]; break; case "false": e.Column.FilterCellAppearance.Image = ilGridImages.Images[1]; break; default: e.Column.FilterCellAppearance.Image = ilGridImages.Images[2]; break; }
I have 2 more minor issues (I know....does it ever end?)
1. Can I change the FilterCell to only show the image? right now, if I hover over it it shows ="true" or ="nonblanks"
2. Can I get rid of the drodown arrow. the image is only 16x16 so the arrow is bigger than the image...minor issue
Sorry for some many questions.
I don't think that article will help, because if you change the column type to Bitmap, filtering won't work.
What I would do is use an UltraCheckEditor control. Place a new UltraCheckEditor on the form with the grid. Set the Style to Custom. Then you can assign images to the CheckedAppearance.Image (for checked) and the Appearance.Image (for unchecked).
Then you just set the grid columns EditorControl property to the UltraTextEditor control. You can use the same UltraTextEditor for as many columns as you need.