Jon Winstanley
Jon Winstanley

Reputation: 23321

Changing the style of Individual cells in a datagridview row

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.

Upvotes: 3

Views: 19661

Answers (2)

Maslow
Maslow

Reputation: 18746

certainly:

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

Upvotes: 3

Gustavo
Gustavo

Reputation: 359

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 + “‘);”);    
  }
}

Upvotes: 0

Related Questions