I am trying to color individual cells on a datagrid. I am unsure whether you actually can or not but here is what i have. I have a datagrid that gets filled by a dataset upon form loading. I also search the cells one by one for the number 376 and I am trying to color those cells. I can get it to color rows but not a cell. If it cannot be done, or you know of another control that would allow for something like this, please let me know. Here is the code.
VB Code:
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load SqlDataAdapter1.Fill(DataSet11) Dim x As Integer Dim y As Integer Dim CellData As String x = 4 y = 4 While x < 7 While y < 7 CellData = DataGrid1.Item(x, y) & "" If CellData = "" Then y = y + 1 Else If CellData = "376" Then DataGrid1.BackgroundColor = System.Drawing.Color.Blue End If y = y + 1 End If End While y = 4 x = x + 1 End While End Sub




Reply With Quote