Jack.D
Jack.D

Reputation: 49

Datagridview specific rows change background color

i try to highlight the selected row become red where column is 'E' in datagridview but if the first row's status is 'E',the following row also become red too although status is 'I'.

enter image description here

SelectionChanged event

int sel = datagridview.SelectedCells[0].RowIndex;
    DataGridViewRow Row = dataGridView.Rows[sel];
    if(!File.Exists(path))
    {
       Row.Cells[4].Value = "E"
       for(int i=0;i<5;i++)
       {
          Row.Cells[i].Style.BackColor = Color.Red;
       }
    }

enter image description here

Upvotes: 0

Views: 289

Answers (1)

Jack.D
Jack.D

Reputation: 49

Just use the dataGridView_CurrentCellChanged event can solve this problem.

Upvotes: 1

Related Questions