在RowSelect属性为false时,DBGrid怎么实现给当前记录加底色?
解决方案 »
- 关于ADO的连接的问题?
- 请问怎样将数据表中的内容显示在excel中?急。。。
- InstallShield打包时,凡是中文文件夹和中文文件名都无法打进去,如何解决?
- 应用程序调用一个已为另一线程整理的界面?(急!在线等待!)
- 哪里有ReportBuilder下载呀???
- 怎样把自已电脑的文件夹共享加密让在局域网内访问时要输入密码!象WIN98共享加密一样!!
- 如何操作操作系统[程序]中菜单?
- Compile\Build有什么区别?
- 求助,关于DSPACK 的视频截取,急急!!!
- delphi中怎样调用package?
- 用ado 联接 oracle DBGrid 显示数据,程序执行时出现"没有侦听"是何缘故。
- ******推荐!不错的一个数据库源码******
TMyDBGrid=class(TDBGridEh);
procedure Tcaxun_form.DBGridEh1DrawColumnCell(Sender: TObject;
const Rect: TRect; DataCol: Integer; Column: TColumnEh;
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;
兄台,你用的是TDBGridEh, 请问TDBGrid能不能实现?
const Rect: TRect; DataCol: Integer; Column: TColumn;
State: TGridDrawState);
begin
with DBGrid1 do
with Canvas do begin
if TMyGrid(DBGrid1).Row = MouseCoord(Rect.Left+1, Rect.Top+1).Y then
Canvas.Brush.Color :=RGB(184,193,225);
DefaultDrawColumnCell(Rect, DataCol, Column, State);
end;
if gdselected in state then exit;
with (sender as tdbgrid).Canvas do
begin
pen.color:=$00ff0000;
moveto(rect.left,rect.bottom);
lineto(rect.right,rect.bottom);
pen.Color:=clbtnface;
moveto(rect.right,rect.Top);
lineto(rect.right,rect.bottom);
end;
end;
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect;
DataCol: Integer; Column: TColumn; State: TGridDrawState);
begin
//如果根据条件改变当前记录颜色的话,在此加入你的条件
self.DBGrid1.Canvas.Font.Color:=clred;//设置当前记录字体颜色
self.DBGrid1.Canvas.Brush.Color:=cl3Dlight;//设置当前记录背景颜色
self.DBGrid1.DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;
procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; const Rect: TRect; DataCol: Integer; Column: TColumn; State: TGridDrawState);
var Row,Col:Integer;
begin
TDrawGrid(Sender).MouseToCell(Rect.Left,Rect.Top,Col,Row);
if Row Mod 2=0 then TDBGrid(Sender).Canvas.Font.Color:=clRed;
TDBGrid(Sender).DefaultDrawColumnCell(Rect,DataCol,Column,State);
end;