procedure TForm1.DBGridDrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if (gdSelected in State) then
begin
DBGrid1.Canvas.Brush.Color:=clYellow;
DBGrid1.Canvas.Font.Color := ClBlack;
end
else
begin
if (DBGrid1.DataSource.DataSet.RecNo mod 2=1) then
DBGrid1.Canvas.Brush.Color:= clGreen
else
DBGrid1.Canvas.Brush.Color:= clRed;
end;
DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
不过要保证你的Query是ADO~否则如果是BDE的话不管用
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if (gdSelected in State) then
begin
DBGrid1.Canvas.Brush.Color:=clYellow;
DBGrid1.Canvas.Font.Color := ClBlack;
end
else
begin
if (DBGrid1.DataSource.DataSet.RecNo mod 2=1) then
DBGrid1.Canvas.Brush.Color:= clGreen
else
DBGrid1.Canvas.Brush.Color:= clRed;
end;
DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
不过要保证你的Query是ADO~否则如果是BDE的话不管用
解决方案 »
- d7中如何点某按钮打开ODBC对话框设置或选择数据源
- 大家一起来讨论一下delphi程序架构的问题
- 有没有Delphi教程、VC++教程、汇编教程、
- 用sql作两张表格比较时出bt错误,请高手指点
- INDY控件 UDp通讯问题?
- 如何改变 TPageControl的Tabsheet的caption的颜色?
- 古有卖炭翁,今有卖葱妇(宝马事件)
- 请问有人知道EnumProcessModules用法吗?
- Delphi也能开发游戏?效率和VC相比怎样??
- single类型如何转换成string型?该用哪个函数?
- 请各位高手给入门者指路
- 如何改变菜单中的字体大小以及如何toolbar中图标大小会按钮大小变化
实战Delphi数据网格色彩特效