In VB .NET I have 3 characters which are added to a DataGridView cell depending on some calculations.
They are rank change arrows and work fine, but I want the up arrow to be green and the down arrow to be red.
Dim strup As String = "▲"
Dim strdown As String = "▼"
Dim strsame As String = "▬"
So in the cell a change of negative three will look like ▼3 and plus 3 will look like ▲3 where the text and symbol are different colors.
How can I change the color of the first character in DataGridView cell?
There is no easy way to do this if you have anything more than just the character in question in the cell (you would need to do some form of custom painting).
If you only have those characters then this is very easy with the CellFormatting event:
If you do want different colors within the same cell then something like the following code is required (this handles the CellPainting event):