I’m trying to change the color of the text of certain rows, but have had zero luck getting this to work. I’ve the documentation and read other posts in the forums, but it hasn’t helped any.
So, I’m just trying to get it to work at a basic level before moving on to more advanced things.
Here’s the basic setup I have:
In the CellTextPaint event I have:
cellName = me.cell(row, column)
if cellName = "Else" then
g.forecolor=RGB(0,0,255)
g.DrawString(Me.Cell(row, column), x, y)
end if
and in the CellClick event I have:
me.invalidateCell(-1,-1)
But the color of the text never turns blue when I click on that cell.
I’ve tried many variations of this, but obviously my brain is missing something crucial.
First If you are drawing the string yourself you need to return True so it is not overwritten by the framework.
Second If all you want to do is change the text color then all you need to do is omit the DrawString, then returning false as the framework will draw it in the forecolor you set… and the the whole code becomes:
if me.cell(row, column) = "Else" then
g.forecolor=RGB(0,0,255)
end if
You need to have Return True in the code in the CellTextPaint event. That tells the framework you are handling the text drawing and color yourself. Return False means nothing gets changed.
cellName = me.cell(row, column)
if cellName = "Else" then
g.forecolor=RGB(0,0,255)
g.DrawString(Me.Cell(row, column), x, y)
Return True
end if
That’s a separate action when I drag the row over to change the text white so that’s it’s viewable while the row on the 2nd listbox is being highlighted.