注意:
dbgrid中可编辑,也就是:dgrowselect为false,现在问题是如何在选中记录时,当前记录行的颜色发生改变,是行而不是单元格。请问如何实现?
dbgrid中可编辑,也就是:dgrowselect为false,现在问题是如何在选中记录时,当前记录行的颜色发生改变,是行而不是单元格。请问如何实现?
解决方案 »
- 判断cxGrid里的有一栏的Properties为LookupComboBox,怎样判断选择了LookupComboBox下拉框的哪一行?
- 急需解决新手的问题,在线急等(本人正在作项目,遇到问题了,请高手指点,有懂c#的更好了)
- 请教大侠,delphi中有没有将一个字符串扩充的函数?
- 如何创建远程数据模块的问题!
- 收集了一些DELPHI开发书籍资料,有时间去看看!
- 关于excel表的问题。
- 请推荐基本介绍socket和分布式开发delphi方面的书籍(在线)
- DELPHI7中如何实现动态图画(.gif格式)
- 数据库图象存储
- 多个edit赋值问题
- CSDN BUG 最新发现,原来这样可以看到裸体MM
- try .. 为什么不能 blockread 起作用?
http://dev.csdn.net/article/53/53439.shtm DBGrid应用全书(一)
http://dev.csdn.net/article/53/53440.shtm DBGrid使用全书(二)
http://dev.csdn.net/article/53/53441.shtm DBGrid使用全书(三)
http://dev.csdn.net/article/53/53442.shtm DBGrid使用全书(四)
http://dev.csdn.net/article/53/53443.shtm DBGrid使用全书(五)
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
with TMyDBGrid(Sender) do
begin
if DataLink.ActiveRecord=Row-1 then
begin
Canvas.Font.Color:=clWhite;
Canvas.Brush.Color:=$00800040;
end
else
begin
Canvas.Brush.Color:=Color;
Canvas.Font.Color:=Font.Color;
end;
DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;end;
type
TMyDBGrid=class(TDBGrid);
的方法可以实现
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
if gdSelected in State then
begin
(Sender as TDBGrid).Canvas.Brush.Color := clInfoBk ;
(Sender as TDBGrid).Canvas.Font.Color := clred;
DBGrid2.DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;end;
http://blog.csdn.net/whbo/articles/232420.aspx
const Rect: TRect; DataCol: Integer; Column: TColumn;State: TGridDrawState);
var i :integer;
begin
if gdSelected in State then Exit;
//定义表头的字体和背景颜色:
for i :=0 to (Sender as TDBGrid).Columns.Count-1 do
begin
(Sender as TDBGrid).Columns[i].Title.Font.Name :='宋体'; //字体
(Sender as TDBGrid).Columns[i].Title.Font.Size :=9; //字体大小
(Sender as TDBGrid).Columns[i].Title.Font.Color :=$000000ff; //字体颜色(红色)
(Sender as TDBGrid).Columns[i].Title.Color :=$0000ff00; //背景色(绿色)
end;
//隔行改变网格背景色:
if Query1.RecNo mod 2 = 0 then
(Sender as TDBGrid).Canvas.Brush.Color := clInfoBk //定义背景颜色
else
(Sender as TDBGrid).Canvas.Brush.Color := RGB(191, 255, 223); //定义背景颜色
//定义网格线的颜色:
DBGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
with (Sender as TDBGrid).Canvas do //画 cell 的边框
begin
Pen.Color := $00ff0000; //定义画笔颜色(蓝色)
MoveTo(Rect.Left, Rect.Bottom); //画笔定位
LineTo(Rect.Right, Rect.Bottom); //画蓝色的横线
Pen.Color := $0000ff00; //定义画笔颜色(绿色)
MoveTo(Rect.Right, Rect.Top); //画笔定位
LineTo(Rect.Right, Rect.Bottom); //画绿色的竖线
end;
end;