C# DataGridView Traffic Light System, Editable DGV


I have a datagridview in my application, the custom wishes to have an interactive datagridview in which then can edit specific cells and reupload to the database.

They also wish to be able to set certain cells to a colour, for example RED/Yellow/Green depending on the stage.

This is currently completed in Access and the report works as both a visual display and as a editable report.  The report is then printed as shown.

I am trying to recreate the report in C# which can be edited/printed and the traffic light system integrated.

They do not mind have checkboxes at the end with Red<> Yellow<> Green<>

I have tried integrating a datagridview and also tried to integrate colours without much luck.  I have Green/Yellow/Red smallints in my database.

I have searched MSDN to look for a solution but so far even trying to foreach every element in the datagrid causes a memory overflow error.

Any help appreciated!  Thanks

Image of the report:  Sensitive data removed but the cells right of the red column are editable.

Report View
Who is Participating?
VBJimConnect With a Mentor Commented:
Just iterate the Grid view once right after you bind.  That should not cause a memory issue
After that, use the cell value changed

Private Sub DataGridView1_CellValueChanged(sender As Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DataGridView1.CellValueChanged
        If e.ColumnIndex = 1 Then
            If Not DataGridView1.Rows(e.RowIndex).Cells(e.ColumnIndex).Value = "" Then
                DataGridView1.Rows(e.RowIndex).Cells(0).Style.BackColor = Color.Red
            End If
        End If
  End Sub

Sorry I coded this is VB but it should be easy to translate
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.