CodePudding user response:
No one will be?CodePudding user response:
I didn't figure to understand your needs, the commonly used search on the net change color code,
Procedure TForm25. DBGridEh1DrawColumnCell (Sender: TObject;
Const the Rect: TRect; DataCol: Integer; Column: TColumnEh;
State: TGridDrawState);
The begin
With DBGridEh1 do
The begin
If (the Rect. Top=DBGridEh1. CellRect (DBGridEh1. Col, DBGridEh1. Row). The Top) and (not
(gdFocused State) in the or not DBGridEh1. Focused) then the begin
//and before a said the current line, changing the=to & lt;> Is in addition to the current row all lines
//and after that said if not input focus or DBGridEh didn't get the focus, that is to say, when there is no selected DBGridEh
//the current line color, selected, in addition to the current line selected cells outside the cell color
DBGridEh1. Canvas. Brush. Color:=clSkyBlue;
//the Current background color of the Windows desktop
End the else begin
If self. ADOQuery2. FieldByName (' whether instructions). AsBoolean then
The begin
Canvas. The Font. Color:=clWindowText;
Canvas, the Font Style:=[];
Canvas. Brush. Color:=clRed;
End
end;
DefaultDrawColumnCell (the Rect, DataCol, the Column, the State);
end;
end;
Procedure TForm1. DBGridEh1DrawColumnCell (Sender: TObject;
Const the Rect: TRect; DataCol: Integer; Column: TColumnEh;
State: TGridDrawState);
The begin
With DBGridEh1 do
The begin
If (gdSelected in State) or (gdFocused in State) then
The begin
If (a DataSource. The DataSet. FieldByName (' status'). AsInteger=201) then the begin
Canvas, the Font Style:=[];
Canvas. The Font. Color:=clLime;
Canvas. Brush. Color:=clMaroon;
end;
End
The else
If (a DataSource. The DataSet. FieldByName (' status'). AsInteger=201) then
The begin
Canvas. The Font. Color:=clNavy;
Canvas, the Font Style:=[];
Canvas. Brush. Color:=clRed;
End
The else
The begin
Canvas. The Font. Color:=clWindowText;
Canvas, the Font Style:=[];
Canvas. Brush. Color:=clWhite;
end;
DefaultDrawColumnCell (the Rect, DataCol, the Column, the State);
end;
//DBGrid1. DefaultDrawColumnCell (the Rect, DataCol, the Column, the State);
How to realize the different line shows different colors in DbgridEh
Release date: 2006.08.15 but source: PLWWW author:
[implementation DBGridEh interlaced color display]
Procedure TForm1. DBGridEh1GetCellParams (Sender: TObject; Column: TColumnEh;
AFont: TFont; Var Background: TColor; State: TGridDrawState);
The begin
If DBGridEh1. SumList. RecNo mod 2=1 then
Background:=$00 ffc4c4
The else
Background:=$00 FFDDDD;
end;
[DBGridEh under certain conditions line shows particular color]
Procedure TForm1. DBGridEh1GetCellParams (Sender: TObject; Column: TColumnEh; AFont: TFont; Var Background: TColor; State: TGridDrawState);
The begin
//in the name field value lines for aaa set the background color (ado Settings)
If ADOQuery1. FieldByName (' name ') AsString='aaa' then
Background:=$00 ffc4c4
//in xm field values for Li Ming lines of setting the background color (bde)
Else if DBGridEh1. The DataSource. The DataSet. FieldByName (' xm). AsString='Li Ming' then
Background:=$00 ffc4c4
The else
Background:=$00 FFDDDD;
end;
The original poster can download this research study:
http://download.csdn.net/detail/wozengcong/5510871
CodePudding user response:
DBGridEh FixedColor attributes can be