Hi all,
I have developed a method that would paint a cell in the DataGridView depending on the value contained in another cell of the same row. This is my code:
This code works only if the column "StatusCode" is visible in the DataGridView.
I would like to paint an "ID" cell ie. Cells(0) and not show the column "StatusCode" in the DataGridView. I was thinking of using the filter and select statement on data source.
Any ideas on how could I do it?
Many thanks!
I have developed a method that would paint a cell in the DataGridView depending on the value contained in another cell of the same row. This is my code:
VB.NET:
Private Sub dgCorpResults_CurrentCellChanged(ByVal sender As Object, _
ByVal e As System.Windows.Forms.DataGridViewCellFormattingEventArgs) Handles dgCorpResults.CellFormatting
' Changes how cells are displayed depending on their columns and values.
' Set the background to red for values 1 in the StatusCode column.
If dgCorpResults.Columns(e.ColumnIndex).Name.Equals("StatusCode") Then
If CInt(e.Value) = 1 Then
dgCorpResults.Rows(e.RowIndex).Cells(0).Style.Back Color = Color.Red
End If
End If
End Sub
This code works only if the column "StatusCode" is visible in the DataGridView.
I would like to paint an "ID" cell ie. Cells(0) and not show the column "StatusCode" in the DataGridView. I was thinking of using the filter and select statement on data source.
Any ideas on how could I do it?
Many thanks!