How to do listbox alternate row coloring? I found this code for listbox alternate row coloring. I’m getting the errors below. I imagine I have to declare some things before. Thanks for the help.
For each row as DatabaseRow in rs
If row Mod 2 = 0 Then
g.DrawingColor = &cf3f6fA
g.FillRectangle(0, 0, g.Width, g.Height)
End If
If it’s from here DesktopListBox — Xojo documentation you need to put it in the PaintCellBackground event and not try to set it when you populate the listbox.
I didn’t ask where you are getting it from; I asked where you are putting it. I told you where it should go and you don’t need to declare g. Your exam question is: why do I not need to declare g.
When I first encountered the ListBox I had the same trouble as you. But by having the code in an event handler, the Framework can compute for us which rows are visible and only call the paint event for those. At least I suppose that’s the raionale.