Click here to Skip to main content
15,881,092 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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!

u can do on rowdatabound like this

VB
e.Row.BackColor = System.Drawing.Color.Red
 
Share this answer
 
v2
Comments
R_D_K 7-May-11 9:10am    
Tks i got solution
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.
 
Share this answer
 
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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900