Click here to Skip to main content
14,836,169 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello guys,

I'm having a problem on how can i set the forecolor of one of the column
in the datagridview which its column item is "Inactive"

like this:

|Name |Status |
|Junil |Active |
|Joyce |Inactive |
|Jein |Active |

I just don't know how to code this one...
Please help me....
Thank you in advance ...
Posted

in the onrowdatabound event of the gridview ou can check values so you can decide if the cell has a specific value you can set the color for that cell
   
Try this.
Dim r As Integer
For r = 0 To DataGrid1.Rows.Count - 1
   If DataGrid1.Rows(r).Cells(1).Value = "Inactive" Then
      DataGrid1.Rows(r).Cells(1).Style .ForeColor = Color.Red
   Else
      DataGrid1.Rows(r).Cells(1).Style .ForeColor = Color.Black
   End If
Next
   
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900