Click here to Skip to main content
14,665,555 members
Rate this:
Please Sign up or sign in to vote.
See more:
How to change the grid view row color wile running onload


i want change the color of the rows if the status columns = Login











Thanks
Posted
Comments
Sandeep Mewara 5-May-11 2:57am
   
can you share your effort if done any? Try!

Rate this:
Please Sign up or sign in to vote.

Solution 1

u can do on rowdatabound like this

e.Row.BackColor = System.Drawing.Color.Red
   
v2
Comments
R_D_K 7-May-11 9:10am
   
Tks i got solution
Rate this:
Please Sign up or sign in to vote.

Solution 2

For changing row's background color and Font color in a datagridview use following lines of code:

int n = 0;
   foreach (DataGridViewRow rw in dataGridView1.Rows)
   {
   // First put a check to avoid newRow error 
   if (rw.Index != dataGridView1.NewRowIndex) // To avoid newRow error 
   {                                          
      // You can replace your condition with the following line
      if (String.IsNullOrEmpty(rw.Cells[0].Value.ToString()) != true)  
      { 
           DataGridViewRow bandrow = dataGridView1.Rows[n];
           DataGridViewBand CatBand = bandrow;
           DataGridViewCellStyle Rwstyle = new DataGridViewCellStyle();
           Rwstyle.BackColor = Color.Lavender;
           Rwstyle.ForeColor = Color.MediumBlue; 
           CatBand.DefaultCellStyle = Rwstyle;
      }
   }
n++;
}


For rest of the points please explain your problem little more.
   
Comments
R_D_K 7-May-11 9:11am
   
tks sk saini i got solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100