Thanks Dave, yes I have and maybe I’m just not getting it?
I understand that while inside the CellBackgroundPaint event, I have access to ‘g’ as a parameter and I can set/get it, etc. What I want to do is outside of that event and what I’m struggling with is: How do I get the graphics object (‘g’) if I’m not in an event that provides it for me, i.e.,
Dim g as graphic = listbox.cell(1,1).???
Sorry to be annoying, but I have read a bit about both the listbox and graphic objects and I’m still unclear?
Short answer: you don’t. Instead you cause the event to happen by using the second part of Dave’s first reply. When you call .InvalidateCell() on a specific cell (from outside that event) then Xojo will call the CellBackgroundPaint event for you.
So your CellBackgroundPaint() event needs enough logic to know what colors and drawing you want to do, but you can modify a CellTag property or anything else needed to the event can decide what it should do when the cell must be (re)drawn for whatever reason. One of those reasons can be using .InvalidateCell() as in Dave’s first reply .
The CellBackgroundPaint and CellTexdPaint events can pass their “G” graphics objects to an outside method, since it is simply a “pointer”… but you cannot access it from outside. By that I mean, the Listbox events can give “G” to another method to use, but another method cannot query the Listbox to retrieve the graphics object.
This same logic/restriction applies to the CANVAS object as well (and technically a listbox cell IS a canvas)