Delphi下DBGrid的自绘

procedure TForm1.DBGrid1DrawColumnCell(Sender: TObject; 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 := 10;
    (Sender as TDBGrid).Columns[i].Title.Font.Color := $000713F3;
    (Sender as TDBGrid).Columns[i].Title.Color := $00F2CED9;
  end;
  
  if ADOTable1.RecNo mod 2 = 0 then
    (Sender as TDBGrid).Canvas.Brush.Color := $00E2E2C7
  else
    (Sender as TDBGrid).Canvas.Brush.Color := RGB(199, 237, 204);
  DBGrid1.DefaultDrawColumnCell(Rect, DataCol, Column, State);

  with (Sender as TDBGrid).Canvas do
  begin
    pen.Color := $00D9D9D9;
    MoveTo(Rect.Left, Rect.Bottom);
    LineTo(Rect.Right, Rect.Bottom);
    Pen.Color := $00FFD9B3;
    MoveTo(Rect.Right, Rect.Top);
    LineTo(Rect.Right, Rect.Bottom);
  end;
end;



上一篇: Delphi检测网络连接状态
下一篇: 提升进程权限为DEBUG权限
文章来自: 本站原创
引用通告: 查看所有引用 | 我要引用此文章
Tags: Delphi DBGrid 自绘
相关日志:
评论: 0 | 引用: 0 | 查看次数: -
发表评论
昵 称:
密 码: 游客发言不需要密码.
邮 箱: 邮件地址支持Gravatar头像,邮箱地址不会公开.
网 址: 输入网址便于回访.
内 容:
验证码:
选 项:
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 1000 字 | UBB代码 开启 | [img]标签 关闭