Forecolor change based on content

hi everyone,
I have a program with a listbox. In this listbox, there are many cells. I would like to change the forecolor of cell 2,3 and 4 based on the content of cell 12. I tried with the event CellTextPaint but I could only paint the whole row. Here’s the the first code:

If me.Cell(row,20) <> “” then
g.ForeColor = &c0000FF
end if

I was able to change the forecolor of a specific cell based on its content using this:

If me.Cell(row,Column) = “Annuel” then
g.ForeColor = &cFF8000
end if

So far, I was not able to change the forecolor of a specific cell based on another.
Could anyone help with me this puzzle please?

You want to change the background color of Cell 5,5 ? Try:

If me.Cell(row,Column) = "Annuel" then If Row = 5 And Cell = 5 Then g.ForeColor = &cFF8000 g.FillRect(0,0, g.Width, g.Height) End If End If

Nota: not tested.

A small bug in Emile’s code:

If Row = 5 And Cell = 5 Then

should be

If Row = 5 And Column = 5 Then

Thanks Dale, that’s it !

Programming before the afternoon nap sometimes is not good…

André ?