Wednesday 4 June 2014

Changing the row color as per column Values

//Changing the row color as per the Stream Value 
private void dataGridView1_CellValueChanged(object sender, DataGridViewCellEventArgs e) 
string strA= dataGridView1.CurrentRow.Cells["ColA"].Value.ToString(); 
strA= strA.Trim(); 
  
if (strA.Equals("India")) 
dataGridView1.CurrentRow.DefaultCellStyle.BackColor = Color.LightSkyBlue; 
else if (strA.Equals("PAK")) 
dataGridView1.CurrentRow.DefaultCellStyle.BackColor = Color.GreenYellow; 
else if (strA.Equals("USA")) 
dataGridView1.CurrentRow.DefaultCellStyle.BackColor = Color.OrangeRed; 
else if (stream.Equals("")) 
dataGridView1.CurrentRow.DefaultCellStyle.BackColor = Color.White; 
  

No comments:

Post a Comment