I populate a listbox (say 5 columns and 20 rows). I want to then look at the value in Col 3 of each row. If the value is >10 then make that cell RED.
Can this be done?
Thanks
I populate a listbox (say 5 columns and 20 rows). I want to then look at the value in Col 3 of each row. If the value is >10 then make that cell RED.
Can this be done?
Thanks
Yes.
See PaintCellBackgroud event for the Desktop list box.
I messed up. What i’m after is to change the color of the font in that cell to a color like red, not the cell background.
Well you could try the documentation for Listbox. It shouldn’t be hard to infer which event you need for this.
Jim’s question is not what trigger; what event, to use. It’s how to specify a color change. He already knows when he wants to do it.
I found “PaintCellText” in the documentation your link brought me to, but I didn’t find any example for changing, for example, cell text from black to red.
English is fun. I can see that the “Paint” in PaintCellText could refer to the act of just displaying (Painting) the text, not coloring (painting) the text.
You can open the example “ListBox Basics” to learn from the examples.
It does not show a cell text color change but it may give you hints on how to do that (as it writes some color boxes on a column if the information of the other column changes).
If you have problems after that, post your code and we can help you.
Edit: Hint, check the StandardListBox - PaintCellText code and you can use something similar of Case 4 - Select case to use on column 3 to change the text to different colors
Thanks all, I’ll take a look at that now…
Alberto
where can i find the “ListBox Basics” example? I didnt see it in the “Examples”
thanks
Bearing in mind that Columns are numbered from zero to N, one possible option would be to have this code in the PaintCellText Event:
If (column = 2) Then
If (Me.CellTextAt(row, column).ToInt64 > 10) Then
g.DrawingColor = &cFF000000
End If
End If
Thanks! Looking at it now.
All - Much thanks for your help and guidance!
Got the below to work - Exactly what I was after - with a little hint from Arthur
If (column = 3) Then
If (Me.CellValueAt(row, column) =“Weak”) Then
g.DrawingColor = color.red '&cFF000000
End If
End If
In this case I looked at a string as opposed to a number (but I’ll use that for another column) in my listbox.