2006. december 12., kedd
How to colour specific cells in a TDBGrid
Problem/Question/Abstract:
Do you know any way to make a row in a DBGrid have a different color. I would like the color to be based on a value in the row. Like a status flag that says if a an account is over 90 days due, show the row in red.
Answer:
Respond to an OnDrawDataCell event. Here's an example that uses the demo COUNTRY table and draws the text of each row in red where the population is less than a certain value.
{ ... }
begin
if Table1.FieldByName('Population').AsFloat < 10000000 then
DBGrid1.Canvas.Font.Color := clRed;
DBGrid1.DefaultDrawDataCell(Rect, Field, State);
end;
{ ... }
Feliratkozás:
Megjegyzések küldése (Atom)
Nincsenek megjegyzések:
Megjegyzés küldése