3

Is it possible to give individual cells in a data grid view row different styles such as backcolor, fontcolor etc?

I do not mean giving the whole row a new style, only a specific cell.

MPelletier
  • 16,256
  • 15
  • 86
  • 137
Jon Winstanley
  • 23,010
  • 22
  • 73
  • 116

2 Answers2

3

certainly:

Me.myDatagridview.Rows(0).Cells(0).Style.ForeColor = Color.Aqua

Siddharth Rout
  • 147,039
  • 17
  • 206
  • 250
Maslow
  • 18,464
  • 20
  • 106
  • 193
0

Something like this?

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
  if (e.Row.RowType == DataControlRowType.DataRow)
  {
      string imageName = e.Row.Cells[0].Text.ToString();
      e.Row.Cells[1].Attributes.Add(“Style”,
        “background-image: url(’images/” + imageName + “‘);”);    
  }
}
Gustavo
  • 359
  • 2
  • 5