custom painting a listbox

In a listbox with rows which do not fill the size of the listbox, there is an area under the last row which doesn’t seem to get painted when using cellbackgroundpaint()

How can I paint into the unfilled area?

in CellBackgroundPaint

If Row>=Me.ListCount then // this row is after the end of the "data"
    g.forecolor=color.red
    g.fillrect 0,0,g.width,g.height
else
   do whatever for a data row
end if

You know, I was convinced that trying to draw when row > listcount would cause an out of bounds error…

Isn’t it with ColumnCount ?

It certainly would if you used that index to try to read data from the list, but if you’re just painting and the event is fired with that higher value there can be no bounds error, as there is no array indexing.

… as was I. Live and learn …