Listbox Background Color Obscure Disclosure Triangle

I have some code in my CellBackgroundPaint event of my listbox. The intent is to color the rows that are “folders” and have disclosure triangles.
Here is the code.

[code] If row <Me.ListCount Then

If (Me.RowIsFolder(row)) Then
  g.ForeColor = &c6666FF
  g.FillRect(0, 0, g.Width, g.Height)
End If

End If[/code]

As desired, the rows that are folders are indeed “colored” but the disclosure triangle itself disappears. I want the disclosure triangles to remain visible.

Is there a way to work around this?

1 Like

actually they are visible… but barely… not sure what you expect to see, putting a gray (&c7d7d7d) triangle over a purplish background… either change the color of your background to something where the contrast between the two colors is greater…
don’t fill in the whole rectangle

g.FillRect(g.height, 0, g.Width, g.Height)

Thanks. My eyesight is not good enough. With the colors that I had chosen, the text was easily visible and I had assumed that the disclosure triangle would be “equally” visible.

But your key point is that gray is not black and the text is black and the disclosure triangle is gray. And it is possible to choose colors (as I had) that leave the text easy to see and the disclosure triangle almost impossible to see. Now I look hard enough and I can see the thing even with my bad color choice.

Anyway I also appreciate the hint of not filling in the entire rectangle. A very complete answer and appreciated

1 Like

If you really really want you can change the triangle color. It’s a fair amount of work but I’ve done it before. The trick is to not add Folder rows. Add only regular rows but with indent to effect the hierarchy. Wrap it in a Listbox subclass overriding certain methods, drawing and handling the triangle clicks and the switcheroo becomes transparent.