Home > Back-end >  Dbgrid component of the zebra crossing
Dbgrid component of the zebra crossing

Time:09-30

 private 
{Private declarations}
ColorA: TColor;
ColorB: TColor;
Public
{Public declarations}
end;

Var
Form1: TForm1;

Implementation

{$R *. DFM}

Procedure TForm1. FormCreate (Sender: TObject);
The begin
ColorA:=$00 bfe4e2;
ColorBox2. Selected:=colorA;
ColorB:=$00 e3fbfb;
ColorBox1. Selected:=colorB;

end;

Procedure TForm1. ColorBox1CloseUp (Sender: TObject);
The begin
ColorB:=ColorBox1. Colors [ColorBox1 ItemIndex];
DBGrid1. Invalidate;
end;

Procedure TForm1. ColorBox2CloseUp (Sender: TObject);
The begin
ColorA:=ColorBox2. Colors [ColorBox2 ItemIndex];
DBGrid1. Invalidate;
end;

Check the color have no reaction, and don't know where is wrong,

CodePudding user response:

To use an DBGrid1. Invalidate; Change the color is no good,
Write in DBGrid1 OnDrawColumnCell event
 if (query1. RecNo mod 2)=0 then 
The begin
DbGrid1. Canvas. Brush. Color:=clRed;
End the else DbGrid1. Canvas. Brush. Color:=clblue;

  • Related