【发布时间】:2015-10-19 02:59:24
【问题描述】:
我对以下示例有疑问。我有一个按钮可以创建包含更多组件的运行时面板:
Panel := TPanel.Create(self);
Panel.Parent := FlowPanel;
Panel.Align := alTop;
Panel.Height := 24;
Panel.Width := FlowPanel.Width;
Text := TLabel.Create(self);
Text.Parent := Panel;
Text.Align := alLeft;
Text.Caption := Query.FieldByName('Nazev').AsString;
Text.AlignWithMargins := True;
Text.Tag := Data_Id;
Text.Width := 100;
Button := TButton.Create(self);
Button.Parent := Panel;
Button.Caption := 'Odstranit';
Button.Align := alRight;
Button.Margins.Top := 0;
Button.Margins.Bottom := 0;
Button.AlignWithMargins := True;
Button.OnClick := DeleteFlowPanelItem;
按钮在 DeleteFlowPanelItem 上有 OnClick 事件;
procedure TAdminTypyPlochy.DeleteFlowPanelItem(Sender: TObject);
var
myPanel: TPanel;
begin
myPanel := TPanel(TButton(Sender).Parent);
myPanel.Free;
end;
当你点击那个时,虽然我的组件被删除了,但是当它弹出消息地址访问冲突时...为什么?
谢谢:)
【问题讨论】:
标签: delphi components destroy