DBGridEh 繪製刪除線

根據數據判斷是否繪製刪除線

  • 示例
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, DBGridEhGrouping, StdCtrls, GridsEh, DBGridEh, DB, DBTables;

type
  TForm1 = class(TForm)
    DataSource1: TDataSource;
    Table1: TTable;
    DBGridEh1: TDBGridEh;
    Button1: TButton;
    procedure DBGridEh1DrawColumnCell(Sender: TObject; const Rect: TRect;
      DataCol: Integer; Column: TColumnEh; State: TGridDrawState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.DBGridEh1DrawColumnCell(Sender: TObject;
  const Rect: TRect; DataCol: Integer; Column: TColumnEh;
  State: TGridDrawState);
begin
    If Table1.FieldByName('Weight').AsInteger >= 20 then
    begin
      With DBGridEh1.Canvas do  
      Begin
        Pen.Color := $0000FF; //定義畫筆顏色(紅色)  
        MoveTo(Rect.Left, Rect.Bottom - 10); //畫筆定位
        LineTo(Rect.Right, Rect.Bottom - 10); //畫藍色的橫線
      End;
    End;

end;

end.

image

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章