改变底色
procedure TscFrmProducePlan.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if ADOQuery1.FieldByName('bUrgentSign').AsBoolean = True then
begin
DBGrid1.Canvas.Brush.Color := clRed;
DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
end;
procedure TscFrmProducePlan.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if ADOQuery1.FieldByName('bUrgentSign').AsBoolean = True then
begin
DBGrid1.Canvas.Brush.Color := clRed;
DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
end;
解决方案 »
- 求助,谁帮我下个东西
- 请问怎样在DELPHI中显示SQL表里的内容,谢谢了
- 为什么DELPHI7的补丁无法安装?
- 在深圳做私活能要多少钱?请有经验的朋友指教
- 如何在调用的窗口中返回值?
- 如何取得状态栏的信息
- 动态创建的问题。。。没见过的.val文件。。。。。
- 怎么样让打印预览中的数据随着数据表的变化而变化?
- 请问adoconectstring 怎么设啊,oledbjet4.0连接access出来的都是绝对路径,怎么让多个client连接到同一个access啊?
- DBImage能否显示JPG数据图形?
- clientdataset更新时的错误处理???????
- 怎么在DELPHI里运行WORLD文件。
procedure TscFrmProducePlan.DBGrid1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if cdsX.FieldByName('bUrgentSign').AsBoolean = True then
begin
DBGrid1.Canvas.Brush.Color := clRed;
DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
end;
格式类似
if .........
then Grid1.Brush.Color:=.......
else grid1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if gdselected in state then
begin
dbGrid1.Canvas.Font.Color:=clwhite;
dbGrid1.Canvas.Brush.color:=clgreen;
dbgrid1.DefaultDrawColumnCell(rect,datacol,column,state);
end;
不过之前,要设置一下dbgrid
procedure TForm1.DBGrid1.DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
if Column.Field = ADOQuery1.FieldByName('xx') then
begin
if Column.Field.AsInteger = 0 then
begin
DBGrid1.Canvas.Brush.Color := clRed;
DBGrid1.Canvas.FillRect(Rect);
DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
end;
end;