Hi Alvin
I am just learning this, I have a grid that has a
DataTable as the source.
I have created the following function:
private void itemcreated(object sender,
DataGridItemEventArgs e)
{
if(((DataRowView).e.Item.DataItem).ItemArray[5].ToString
() == "0")
{
e.Item.Cells[5].BackColor = System.Drawing.Color.Red;
}
}
I have then specified that the datagrid should use this
function when OnItemCreated is fired.
This gives me an access violation that I guess is due to
the fact that I have a DataTable as the source. I think
that I am on the right track since removing the if
statement colors the column red as I want.
TIA
-----Original Message-----
What you want is the BackColor property on the DataGrid
object. It takes aColor enum
Color.Red for example
regards
--
-----------
Got TidBits?
Get it here: www.networkip.net/tidbits/default.htm
"John Doe" <an*******@discussions.microsoft.com> wrote in
messagenews:0c****************************@phx.gbl... Hi
Is it possible to set the background colour of a grid
based on a value in data?
I guess that it is simple but I have been unable to
figure it out.
TIA
.