Cell Backcolor not work - mission impossible

I’ve tried them all, I can’t color the background of a cell in a ListBox. I managed to color the cell text, make the cell text bold, but I can’t color it.

In code: ListBox1.CellBoldAt(r,c)=TRUE (OK)

in PaintCellBackgrounf
g.DrawingColor= &cD2D2D2
g.FillRectangle(0, 0, g.Width, g.Height) (OK)

in PaintCellText

if g.bold=True then
g.ForeColor = color.red
end if (OK).

but how do you color the background of a cell?

This paints “the background” of a cell
not sure what else you’re expecting to do ?

1 Like

I think you have to return True from the PaintCellBackground event to prevent the system from wiping out your painting.


Indeed you do

PaintCellBackground(g As Graphics, Row As Integer, Column As Integer) As Boolean

The parameter g is a Graphics object that corresponds to the content area of the cell identified by the parameters Row, Column. 0,0 is the upper left of the cell. Returns a Boolean. True means the user has handled the drawing of the background and no other processing is to be done with the background. In this case the user is responsible for all highlighting. False means the user wants the default background; this will overwrite your drawing on the row that needs to be highlighted as the row or column will be highlighted as appropriate (according to the platform and the hierarchical style).

@Fede many of these things are in the documentation

Do you try to find them there first
And I understand if you don’t as the new documentation is, in my opinion, not as nice to search as the old ones

Yes, I solved it. I have read a lot and have seen some examples. I was able to complete everything I wanted to do. In fact it is not easy for me to find references, many times I get “deprecated” and I have to discover the new argument … but slowly I go on. Thanks as always for the support.