Listbox CellClick Q.

Hello,

I usually like having Xojo handle my selected color using the blue and it automatically makes my text in that cell white. However if I have an image drawn in using cellbackgroundpaint it becomes covered when I select that cell. Is there a way to still have Xojo handle the highlighting of the cell, but also make my g.drawpicture come to the foreground by chance? (besides returning true in cellclick and handling the highlighting myself).

Thanks!
Mike

Can you use Listbox.RowPicture instead of drawing it yourself?

Or you can try CellTextPaint which happens after the highlight is drawn. Or figure out the highlight color and fill that too (I don’t know a good way to get that color).

Ah I never tried that (RowPicture) nor trying celltext paint for the image.

Ill try that thanks Will.

Brilliant thank you Will. I put the image in the CellTextPaint and now it shows when selected along with the Text.

Thank you! :slight_smile:

Don’t forget to invert Textcolor and/or graphics for selected cells:

CellBackgroundPaint Event:

  #pragma BackgroundTasks false
  #pragma unused column
  
  g.forecolor=RGB(33,107,170)
  if me.selected(row) then g.ForeColor = RGB(255,255,255)
  
  g.FillRect 0,0,g.width, g.height
  
  #pragma BackgroundTasks true

CellTextPaint Event:

if Me.Selected(row) then me.celltag(row,0) = key25 else me.celltag(row,0) = key25white if column = 0 then Dim p as picture = me.celltag(row,0) if p <> nil then g.drawPIcture p, x, 6, 25, 25, 0, 0, p.width, p.height end if

I am using Celltag as Icon Container cause it’s sometimes easier when using hierarchical listboxes.
Key25 is the name of an image, key25white is the inverted version of same image,
x,y and sizes need to be adjusted.

Thanks Tomas! Since I am still letting Xojo handle the highlighting the invert of white is automatic still. thanks again!!