Anyway of Adding conditional image to a DBAdvGrid

Here’s what I’m trying to do; I have a read only DBAdvGrid
with a Boolean field in the database what I want is to display a graphic rather
than the greyed out tick box.

<?: prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>

I feel this should be doable but I’ve been looking at it for
two days now and none of things I’ve tried have worked, I’ve tried linking to
an ImageList via an ImagePickerEditLink as well as using a custom control via a
FormControl Edit Link and one of three things happens:

<o:p> </o:p>

  • The Tick Box appears
  • Nothing Appears
  • Runtime error (if the column is setup as a graphic)

<o:p> </o:p>

Any help would be greatly appreciated

Your message subject indicates something different than the content of your post imho.

If you want conditional images, please have a look at the demo ADODataImage that demonstrates this.
Do you also need to be able to edit this? Is this just a boolean field, if so, that can't be edited with an ImagePickerEditKLink. If this is a boolean field , ie. just toggles between true & false, I'd suggest to handle this from the OnCellClick event and toggle your DB field value from there.

Thank’s Bruno, the title may of lost something when I
trimmed it to fit the available space but

yep, that’s what I’m trying to do so that if the field is
True a green tick appears and false a red x appears.

<?: prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>

I’d already attached the Image List to the gridimages  property and, even looking at the demo, can’t
see how to effect the change. I can see looking at your sample data the Country
field is a numeric field which relates to the off set in the Imagelist but I
just can’t see how your actually putting the image in place as there is no code
attached to the grid I know it must be a setting somewhere that I’m missing.

You can download a sample here:

http://www.tmssoftware.net/public/ImageCheckBox.zip 

Thanks again, I see where you’re going with this one in that your using a calculated field to return an integer value for the imagilist offset the thing I’m probably being a bit thick about is how does the grid know to display the graphic instead of the value?

<?: prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Also, before I went down this route, I tried using the grids ControlLook Property which, although it allowed me to have an active looking, rather than greyed out, check box it still did not replace the check box with the desired bitmap.

By the way in this case the Grid can only be read only as its attached to an SQL joined table, if it helps the field can be stored as an integer instead of Boolean as this is a late addition to the project and wasn’t included in the formal specification accepted by my client.

If you want that an image is displayed for a DB field, set grid.Columns[index].DataImageField = true.


About ControlLook, did you set grid.ControlLook.ControlStyle = csGlyph?

Thanks, no I haddn't noticed the csGlyph setting and using the ControlLook method got the result I needed, I'll revisit the bitmap method when I've got more time, Thanks again for all your help.