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!

Set Color in Datagrid

Status
Not open for further replies.

sern

Programmer
Jan 8, 2003
31
MY
Hello all.
I wish to display my data in different colors in datagrid.
Let say I have data: Name, Age, Address. If age is more than 20 then display the record in blue color. Otherwise display it in red color.
Anyone please help on this. Thanks.
 
Use the Flexgrid rather than the Datagrid, then you can set individual cell backcolors. To change the background of a whole row for example:

fg1.Row = 2
For i = 0 To fg1.Cols - 1
fg1.Col = i
fg1.CellBackColor = vbGreen
Next i

will colour the whole of the third row green

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Dear johnwm,
Is it means that I can't do the same thing in datagrid? It is better if I can get the datagrid works rather than flexgrid.
 
AFAIK you can't easily change individual backcolours in the Datagrid (but I stand to be corrected!)

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 

>but I stand to be corrected

Take a seat.

johnwm is correct.
The only thing you can change the color/fonts on is the that for all records/columns to be identical, or just the active cell (and the latter via API call).
 
OK. Thanks all. I will try to use flexgrid.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top