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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Colors in Datagrid

Status
Not open for further replies.

DwaineC

MIS
Jan 6, 2003
40
0
0
US
Can I set a color scheme (or cell style) for individual cells? I simply want the foreground and background color of certains cells to be different than the rest, dependent upon the data. Since it is a bound grid, I will traverse the cells and check the data one by one... but I can't find any cell property which allows me to change the colors for a single cell...

Thx in advance...
 
I did find that in another post and yes, it does work. I chose to override the paint event in an inherited DataGridTextBoxColumn. Seems a little silly to have to do all that, but... it works. I can understand making controls more flexible - but they certainly could have simply added a cell color property...

Thx for your response...

Dwaine
 
I have a related question. I have several columns which are color coded depending on their cell contents. The grid is loaded and looks great. The user needs to change this cells and the color should also change. I not sure which event to override. I thought about the invalidate event to force a paint to occur. Will this repaint the entire grid or just the one cell ?
 
Markinro,

Create a DataTextBoxcolumn for each column you wish to override the paint event. Add that column to the gridstyle and you will be on your way. Within the overrided paint event you'll know the row being updated and you can trap for the cell data and choose your color brushes.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top