【发布时间】:2019-11-14 20:40:26
【问题描述】:
所以我创建了一个基于 cxButton 的自定义按钮。我希望在单击此按钮时显示一个弹出菜单。但由于某种原因,弹出菜单没有出现。 我什至没有收到错误,我不知道为什么。
type
TcxGridButton = class(TcxButton)
private
FGridView : TcxGridDBTableView;
FPopup : TPopupMenu;
procedure AutoSize(Sender : TObject);
procedure ClearFilter(Sender : TObject);
protected
{ Protected declarations }
public
{ Public declarations }
constructor Create(AOwner : TComponent); override;
procedure Click; override;
published
property GridView : TcxGridDBTableView read FGridView write FGridView;
end;
这是我创建弹出菜单的部分
constructor TcxGridButton.Create(AOwner: TComponent);
var Item : TMenuItem;
P : TPoint;
begin
inherited;
Text:='Options';
FPopup := TPopupMenu.Create(Self);
Item := TMenuItem.Create(FPopup);
Item.Caption:='Nach Excel exportieren';
Item := TMenuItem.Create(FPopup);
Item.Caption:='Automatische Größenanpassung';
Item.OnClick:=AutoSize;
Item := TMenuItem.Create(FPopup);
Item.Caption:='Filter löschen';
Item.OnClick:=ClearFilter;
end;
现在,当我将此按钮放在表单上时,它会立即显示文本选项,因此构造函数似乎运行正常。
但是当我点击这个按钮时,我得到了 Click 、 Self.ToString 和 Done。 但是 Popup 菜单永远不会 Pops up 。我的错误是什么?
procedure TcxGridButton.Click;
begin
inherited; // call the inherited Click method.
ShowMessage('CLICK');
if not Assigned(FGridView) then Exit;
ShowMessage(Self.ToString);
FPopup.Popup(0,0);
ShowMessage('DONE');
end;
【问题讨论】:
标签: delphi events components