Change color on condition for datagrid cell

  • Thread starter Thread starter Billy Jacobs
  • Start date Start date
B

Billy Jacobs

I have a bound datagrid and I want to set the cells of any
item of a certain column whose value is greater than 100
to a different color.

How do I accomplish this?
 
Hi Billy,

Thanks for your post. I'd like to share the following information with you:

1. If it's a DataGrid web control, you can use the DataGridItem.BackColor
property to set the color of certain cells. Please refer to the following
sample:

Conditional Formatting ASP.NET DataGrid Columns
http://www.codeproject.com/aspnet/gridcolumnformatting.asp

2. If you are using DataGrid WinForm control, you will need to override the
Paint() method to draw the backcolor of certain cells. The following
articles provides more detailed information on this subject:

http://www.syncfusion.com/FAQ/WinForms/FAQ_c44c.asp?print=745

Changing the background color of cells in a DataGrid
http://www.codeproject.com/csharp/custom_datagridcolumnstyl.asp

Please feel free to let me know if you have any problems or concerns.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
That worked. Thanks.

-----Original Message-----
Hi Billy,

Thanks for your post. I'd like to share the following information with you:

1. If it's a DataGrid web control, you can use the DataGridItem.BackColor
property to set the color of certain cells. Please refer to the following
sample:

Conditional Formatting ASP.NET DataGrid Columns
http://www.codeproject.com/aspnet/gridcolumnformatting.asp

2. If you are using DataGrid WinForm control, you will need to override the
Paint() method to draw the backcolor of certain cells. The following
articles provides more detailed information on this subject:
print=745

Changing the background color of cells in a DataGrid
http://www.codeproject.com/csharp/custom_datagridcolumnsty l.asp

Please feel free to let me know if you have any problems or concerns.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

.
 
Back
Top