RowPicture parameter??

Hi,
whilst looping through and adding rows to a listbox, what do I put in the RowPicture parameter???

I have tried LastIndex and -1 but neither work.
LastIndex causes a “This Item Does Not Exist” error, and -1 raises an Out Of Bounds exception.

Perplexed now as to how to insert an image when creating the row :frowning:

while not Recordset.eof Window1.myListbox.addRow Window1.myListbox.RowPicture() = myImage Recordset.moveNext wend

Thank you in advance.

Window1.myListbox(lastindex).RowPicture = myImage

Jeff,
that causes a syntax error, and a parameter is also needed for RowPicture.

It also says: “This Item Does Not Exist” for ListIndex??

Yup.
typed faster than I should: rowpicture does want a row number. I could have sworn it was a property of the row.

This code works and should show you all you need:

[code] dim x as integer
dim p as picture
p = new picture (16,16,32)
p.graphics.ForeColor = &cff0000
p.graphics.filloval 2,2,14,14

for x = 1 to 10
Listbox1.AddRow
listbox1.RowPicture(listbox1.lastindex) = p
next
[/code]

Hmmm,
This is my updated code:

while not Recordset.eof Window1.myListbox.addRow Window1.myListbox.RowPicture(Window1.mylistbox.LastIndex) = myImage Recordset.moveNext wend

However, the image looks like a tiny line, as in the screenshot below:

It should be a 32x32 image of a file.
The listBox row height is 30pixels.

Any ideas?

Rowpicture likes 16 x 16 icons.

You need to use cellTextPaint or CellBackgroundPaint

I put this into the Open event of a window:

[code] dim x as integer
dim p as picture
p = new picture (32,32,32) //note bigger size this time!

p.graphics.ForeColor = &cff0000
p.graphics.filloval 2,2,30,20

for x = 1 to 10
Listbox1.AddRow
listbox1.RowTag(listbox1.lastindex) = p

next[/code]

and this in the CallBackGroundPaint of the listbox

if row < me.listcount then //dont paint on virtual rows if me.rowtag(row) <> nil then //dont paint of there is no tag g.drawpicture me.rowtag(row),0,0 end if end if

It has to check that the row is a REAL row, as this fires for the spaces between the last row and the bottom of the listbox

Jeff,
I kept my updated code as per my previous post, but resized the images from 32 x 32 to 16 x 16 - and it now works perfectly.

It therefore seems as if it does not need to be in the CellBackgroundPaint event?

[quote]resized the images from 32 x 32 to 16 x 16 - and it now works perfectly.

It therefore seems as if it does not need to be in the CellBackgroundPaint event?[/quote]

Thats correct.
Rowpicture does the work for you if you can live with 16 x 16 , but it can look a bit iffy if you change the font size / row height to something larger.
Thats when you have to resort to painting in an event instead.

All I need to do now is work out what Retina Kit code I need in order to display the correct image resolution.