I would assume that the icons might have been painted, but then got out of scope and became nil, so then no longer get painted. Except for the last one which you still hold a reference to.
To be able to put something in Row 0, Cell (or Column) 1, you have to add one Row and to explicitely say so. Dont you ?
// Add one Row and Text in Column 0
Listbox1.AddRow "This is column 0"
Loc_Row = Listbox1.LastIndex // Get the # of the last added Row #
Listbox1.Cell(Loc_Row,1) = "This is Column 1" // Text added in Column #1
For text (or string), that is what I meant. For drawings, I meant the same; something like (pseudo-code):
If Row = 1 And Cell = 2 Then
// Put here code to draw the icon
End If
Is it clear now ?
Also, Get an eye on the LRs Refresh: it will say that this is deprecated, use Invalidate.
You are not returning True to cancel the standard BackgroundPaint behavior, so even if I wonder why the icon appears on the last row though maybe this will help?
I’ll try to keep this simple; drawing images via OS API in a listbox doesn’t work, the simplest route is to draw them to a Xojo Picture first, then draw that Xojo picture.
Alternatively, just think of the listbox as a canvas (which I actually believe it is), to which you can use OS API to draw images, however you must do the math yourself. Apple do system drawing, from the bottom-up (some would say the same as their current product line-up), where as Xojo does it’s top-down.
0, 0 is top left in Xojo, but is bottom left in macOS.
get the folderitem
get the icon
Create a new Picture,
Draw the icon into that Picture
Add a row to the listbox
set the rowtag(thelist.lastindex) = thepicture
And in the cellbackgroundpaint event, do something like this:
[code]
if row < me.listcount-1 and me.rowtag(row) <> nil then