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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.