Question

This is with respect to the language C#.

I want to use the last column in a DataGridView as a color column. The Row in the list will have some data and the last column cell of that row will have a color to represent if it is right or wrong, good or bad. (something like that) Is it possible to do this and how (if possible)?

Was it helpful?

Solution

After setting datasource, you may use-

        foreach (DataGridViewRow row in yourDataGridView.Rows)
        {
            if (row.Cells[LastColumnIndex].Value == YourValue)
            {
                row.Cells[LastColumnIndex].Style.BackColor = Color.Red;
            }
        }

Hope, you have got the idea.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top