cellbackgroundpaint

I am trying to draw border around certain columns in a listbox. The following code works:

if column = 2 then g.forecolor=&cff0000 g.DrawRect 1,1,g.width-2,g.height-2 end

However, I dont want a border around any cell that belongs to a row that is a folder. I tried to alter the above code to:

if column = 2 AND NOT Me.RowIsFolder(row) then g.forecolor=&cff0000 g.DrawRect 1,1,g.width-2,g.height-2 end

But this results in an outofbounds error. My guess is that the data is not available yet. So is there any other way I can achieve this?

The event will fire for every visible row, even if you don’t have that many rows added… If you do .AddRow ten times, but your listbox’s height is enough that twelve rows will be visible, the event will be called twelve times…

if (column = 2) AND (row < me.ListCount) AND (not me.RowIsFolder(row)) then g.forecolor=&cff0000 g.DrawRect 1,1,g.width-2,g.height-2 end

This will only draw the rect for the rows you added… Not too certain how you want to handle blank rows…

[quote=178395:@shao sean]The event will fire for every visible row, even if you don’t have that many rows added… If you do .AddRow ten times, but your listbox’s height is enough that twelve rows will be visible, the event will be called twelve times…

if (column = 2) AND (row < me.ListCount) AND (not me.RowIsFolder(row)) then g.forecolor=&cff0000 g.DrawRect 1,1,g.width-2,g.height-2 end

This will only draw the rect for the rows you added… Not too certain how you want to handle blank rows…[/quote]
Perfect thanks.