سؤال

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

هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top