Frage

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)?

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top