Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DataGrid - Conditional ROW color

Status
Not open for further replies.

SKYplus

Programmer
Jul 18, 2001
9
MT
Hi,

i have a DataGrid which is readonly and is taking data from a DataTable.
I want to change the row color when a particular cell is in a certian value.

if anyone can help please let me know !!
 
This is an example:

foreach(DataGridItem item in DataGrid1.Items)
{
if(item.Cells[3].Text.ToString() == "154")
{
item.BackColor = Color.Blue;
item.ForeColor = Color.Red;
}
}

Remark: in 'Cells[3]', 3 is the position of column in datagrid (in this column is the value you look for -- here, the value is "154").


Hope this help,

Mary
 
Hi Mary,

thanks for the reply...

however I forgot to mention that it's the windows forms datagrid, so this method doesn't work because it doesn't have the items property.. and therefore i can't do like that :(

anyone else knows? please
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top