gpt4 book ai didi

delphi - 触发 TDBGrid 列大小调整事件的位置

转载 作者:行者123 更新时间:2023-12-02 10:28:22 32 4
gpt4 key购买 nike

我有一个 TDBGrid 组件。我需要捕获调整网格列大小时触发的事件。

最佳答案

获取事件的唯一位置似乎是重写 ColWidthChanged...

type
TDBgrid=Class(DBGrids.TDBGrid)
private
FColResize:TNotifyEvent;
procedure ColWidthsChanged; override;
protected
Property OnColResize:TNotifyEvent read FColResize Write FColResize;
End;

TForm1 = class(TForm)
Panel1: TPanel;
Button1: TButton;
DBGrid1: TDBGrid;
ADODataSet1: TADODataSet;
DataSource1: TDataSource;
procedure FormCreate(Sender: TObject);
private
procedure ColResize(Sender: TObject);
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

{ TDBgrid }

procedure TDBgrid.ColWidthsChanged;
begin
inherited;
if Assigned(FColResize) then FColResize(self);

end;


procedure TForm1.FormCreate(Sender: TObject);
begin
DBgrid1.OnColResize := ColResize;
end;

procedure TForm1.ColResize(Sender:TObject);
begin
Caption := FormatDateTime('nn:zzz',now) ;
end;

关于delphi - 触发 TDBGrid 列大小调整事件的位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15063680/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com