如何在自定义网格控件中响应调整大小事件? [英] How do I respond to a resize event in my custom grid control?

查看:74
本文介绍了如何在自定义网格控件中响应调整大小事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Delphi的新手,我正在构建一个从TStringGrid派生的自定义控件。我需要访问OnResize事件处理程序。我如何获得它? TStringGrid的父级有一个OnResize事件

I am new to Delphi and I'm building a custom control derived from TStringGrid. I need access to the OnResize event handler. How do I get access to it? TStringGrid's parent has a OnResize event

推荐答案

发布 OnResize 事件,该事件在 TControl 中受默认保护。

Publish the OnResize event, which is protected by default in TControl.

在自己的子孙中,您不应使用事件本身,而应使用触发事件的方法。这样做将使您的组件用户有机会实现自己的事件处理程序。

In an own descendant, you should not use the event itself, but rather the method that triggers the event. Doing it that way will give the users of your component the opportunity to implement an own event handler.

重写Resize方法:

Override the Resize method:

type
  TMyGrid = class(TStringGrid)
  protected
    procedure Resize; override;
  published
    property OnResize;
  end;

{ TMyGrid }

procedure TMyGrid.Resize;
begin
  // Here your code that has to be run before the OnResize event is to be fired
  inherited Resize; // < This fires the OnResize event
  // Here your code that has to be run after the OnResize event has fired
end;

这篇关于如何在自定义网格控件中响应调整大小事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆