Change cell color

2

I need to change the color of the cell:

I'm doing it this way

 dataGridView.Rows[rowIndex].Cells["nomeDaColuna"].Style.BackColor = Color.Yellow;

But I can not get past the rowIndex I would have to pass the "line name"

    
asked by anonymous 30.11.2015 / 08:24

1 answer

0
  • Could you explain what you want to do and what result you want to achieve?
  • What do you mean by "line name" and why does it have to be the "line name"?
  • So, there are no names for the grids lines in DataGridView as far as I know, but you can create a dictionary for this, work, so I think it's best to think what you want to achieve in the end before and plan a little.

    dataGridView.Rows[0].HeaderCell.Value = "NomeDaLinha1";
    dataGridView.Rows["NomeDaLinha1"].DefaultCellStyle.BackColor = Color.Yellow;
    

    It would be something like this, but you would have to specify the names of each line.

      

    Warning: The above code has not been tested.

        
    30.11.2015 / 10:57