|
Subject:
|
Colouring Rows in a Datagrid
|
|
Posted By:
|
Louisa
|
Post Date:
|
8/15/2005 4:27:41 AM
|
I have a datagrid and I would like to be able to alter the colour of row depending upon the data in the grid for example making all customers from Kent green and Hampshire yellow. How do I do this?
Thanks
Louisa
|
|
Reply By:
|
RPG SEARCH
|
Reply Date:
|
8/15/2005 7:09:05 AM
|
try 4guysfromrolla.com they have a good guide to the datagrid....
i think an if statement might cover it like...
If DatagridLbl1.Text = "Kent" then ItemStyle.BackColor = Red ElseIf Datagridlbl1.text = "Somewhere Else" then ItemStyle.BackColor = Pink with dots End If
David Jenkins ------------------------------------------------------------- Do you want to make extra money around your commitments? Credit cards, bills, loans and a mortgage - all getting you down? Is your pension going to be enough when you retire? There is a solution visit http://www.1stmillion.co.uk or call 01772 489521
|
|
Reply By:
|
avanishp
|
Reply Date:
|
8/16/2005 8:51:19 AM
|
private void usrGrid_OnItemDataBound(object sender, DataGridItemEventArgs e ) { if(e.Item.Cells[0].Text=="Kent") e.Item.BackColor=Color.Green; if(e.Item.Cells[0].Text=="Hampshire") e.Item.BackColor=Color.Yellow; }
here Cells[0] in cell having text to check, you have to change it to cell index you have for this text.
Avanish Pandey Set your heart upon your work, but never on its reward
|