Design as follows in the data grid view;
Date Session VRV CK CNN CKK MS T MS RK MK
8/1/2012 1 COURSENAME
8/1/2012 2
8/1/2012 3
8/1/2012 4
in the above i want to give the FORECOLOR for DATE and SESSION in the data grid view.
Loading

Riddhi ValechaRank #794 · 2.9K reputationPosted Jan 8, 2013, 3:19 AM EST
Try the following -
protected void RowClicked(object sender, GridViewRowClickedEventArgs e) { GridViewRow newrow = (GridViewRow)GridView.Rows[e.Row.RowIndex]; newrow.BackColor = Color.Blue; newrow.ForeColor = Color.White; if (ViewState["rowindex"] != null && (int)ViewState["rowindex"] != e.Row.RowIndex) { GridViewRow oldrow = (GridViewRow)GridView.Rows[(int)ViewState["rowindex"]]; oldrow.BackColor = Color.Empty; oldrow.ForeColor = Color.Black; } ViewState["rowindex"] = e.Row.RowIndex; } This works... Hope this helps you out...chellappan pandiarajan79 reputationPosted Jan 8, 2013, 5:43 AM EST
For Particular coloumn : GridName.Columns[1].DefaultCellStyle.ForeColor = Color.Red;
For Particular Row : GridName.Rows[1].DefaultCellStyle.ForeColor = Color.Red;
Here [1] denotes the Index
Thanks,
Pandian
Satyapriya NayakRank #47 · 31.5K reputationPosted Jan 8, 2013, 5:55 AM EST
dataGridView1.Columns[1].HeaderCell.Style.ForeColor = Color.Red;
dataGridView1.EnableHeadersVisualStyles = false;
Satyapriya NayakRank #47 · 31.5K reputationPosted Jan 8, 2013, 6:59 PM EST
{
dataGridView1.Rows[i].Cells[0].Style.ForeColor = Color.Red;
dataGridView1.Rows[i].Cells[1].Style.ForeColor = Color.Red;
}
If this post helps you mark it as answer
Thanks