fill in a color in the full row

Dim Color As New Picture(me.width, me.height, 32)
Color.Graphics.ForeColor = &cff69b4
Color.Graphics.FillRect(0,0,Color.Width,Color.Height)

me.RowPicture(currentrow) = Color

SO i this code fils in only the first cell within the currentRow.
I would like to fill in all the cells within the currentRow.

please advise.

CELLBACKGROUNDPAINT event

if row=currentrow then 
g.forecolor=&cff69b4
g.fillrect 0,0,g.width,g.height
end if

Hi dave thank for the fast repsonse.

I cannot use g
that would mean i would have to use the cellBackGroundPaint(g as graphic …
and at this point I am using ListBox.CellTextChange to sense when a cell has been changed, then i change to the color of the current row when the user changes a value in error, so i need to use CellTextChange or CellLostFocus

Uh… so?
Those events are not limited to one circumstance…
As as matter of fact, for the most part I put “RETURN TRUE” in CELLTEXTPAINT and handle EVERYTHING in CELLBACKGROUNDPAINT.
The background color, the color if it is a selected row, any/all graphics, icons, or shapes, and finally the text itself… selecting the appropriate colors at each step to get the desired affect.

All “RowPicture” does is hold a picture to slap into the first cell after all the other “G” drawing has been done (or maybe its before), but either way its the same thing

If you need to force a cell to update (due to an error etc)… use INVALIDATECELL(row,col)

currently in my project i have the following code in CELLBACKGROUNDPAINT

If row Mod 2 = 0 Then g.ForeColor = &cf3f6fA g.FillRect(0, 0, g.Width, g.Height) End If

is it possible to add your earlier suggested code to CELLBACKGROUNDPAINT?

if row=currentrow then g.forecolor=&cff69b4 g.fillrect 0,0,g.width,g.height end if

also if the user edits the text in CELLTEXTCHANGE how does that trigger the CELLBACKGROUNDPAINT ?

If row Mod 2 = 0 Then g.ForeColor = &cf3f6fA
if row=currentrow then g.forecolor=&cff69b4
g.fillrect 0,0,g.width,g.height

INVALIDATECELL … as I mentioned above

i see now.

Thank you

Dave,

It has been a while on … just recently i revisited this routine and found that it was not working for some reason.
my routine does change the row color via CellBackgroundPaint, but then whites it out again. I set a default color as &cffffff ( white ) … if i don’t set a default my routines will produce a black row highlight.

put simply, i loading a window which on “open” loads data into a ListBox with 8 columns… then i change the background of each row based on the data … white, red, and pink.

hopefully someone can spot where my error is …

CellBackGroundPaint

[code]If row Mod 2 = 0 Then
g.ForeColor = &cf3f6fA
g.FillRect(0, 0, g.Width, g.Height)
End If

if row = currentRow Then
g.ForeColor = currentColor
g.FillRect(0, 0, g.Width, g.Height)
end if[/code]

Open Event For Window

[code]Dim iniFolder As FolderItem = MainWin.DataFolder.Child(“inv”).Child(MainWin.ItemCode.Text + “.inv”)
Dim r As Integer

currentColor = &cffffff

if iniFolder <> Nil and iniFolder.Exists Then
ListBoxLoadFromFile(Inventory, iniFolder, 8)
End if

for r = 0 to Inventory.ListCount - 1
currentRow = r
currentColor = CheckItemUsedStatus(Inventory, r)

//Inventory.InvalidateCell(r, 0)
msgbox "row: " + str® + " currentColor: " + str(currentColor)
next r
[/code]

CheckItemUsedStatus

[code]Dim qtybc, soldbc As Integer
Dim usedrow As Integer

qtybc = Val(iBox.Cell(row, 3))
soldbc = Val(iBox.Cell(row, 7))

If qtybc = soldbc Then ’ PINK
return &ce6b6e7
ElseIf soldbc > qtybc Then ’ RED
return &cffb389
Elseif qtybc < soldbc then ’ WHITE
return &cffffff
end If

// default return white
return &cffffff
[/code]

[code]g.ForeColor = &cffffff
If row Mod 2 = 0 Then g.ForeColor = &cf3f6fA

if row = currentRow Then
Dim qtybc, soldbc As Integer
qtybc = Val(me.Cell(row, 3))
soldbc = Val(me.Cell(row, 7))

If qtybc = soldbc Then g.ForeColor = &ce6b6e7
If soldbc > qtybc Then g.ForeColor = &cffb389

end if

g.FillRect(0, 0, g.Width, g.Height)
[/code]

Jeff,
ah yes your setting the dafault to white and you put the full routine within the CellBackgroundPaint Event.
with this code you provided i get the “MOD” coloring , but i do not get any currentRow coloring …

i am using this code to change the row during open event.

[code]if iniFolder <> Nil and iniFolder.Exists Then
ListBoxLoadFromFile(Inventory, iniFolder, 8)
End if

for r = 0 to Inventory.ListCount - 1
currentRow = r
Inventory.InvalidateCell(r, 0)
// msgbox "row: " + str® + " currentColor: " + str(currentColor)
next r
[/code]

You should store the color in the RowTag of each row. Then it will be readily available in CellBackgroundPaint.

In your current code, the value of currentColor is whatever the last row is. CellBackgroundPaint is called long after the Open event, even if you invalidate cells. And CellBackgroundPaint is called repeatedly. Every time, for every row, you need to determine the color for this row at this time. You only have a single value for currentColor, but every row uses it. Drawing in the listbox is disconnected from your code in the open event. Put another way, the listbox doesn’t remember what color each row is, it is recreated fresh every time.

[quote]ah yes your setting the dafault to white and you put the full routine within the CellBackgroundPaint Event.
with this code you provided i get the “MOD” coloring , but i do not get any currentRow coloring[/quote]

OK… think about it…
Im assuming currentrow is populated by you and has a value between 0 and listcount
If all you mean is ‘the selected row’ then there is simpler code for that:

if row = me.listindex Then
Dim qtybc, soldbc As Integer
qtybc = Val(me.Cell(row, 3))
soldbc = Val(me.Cell(row, 7))

If qtybc = soldbc Then g.ForeColor = &ce6b6e7
If soldbc > qtybc Then g.ForeColor = &cffb389

end if