...public
Destructor Destroy;override;
...Destructor TMyComboBox.Destroy;
begin
Items.Clear;!!!!该句会导致异常,说是MyComboBox1没有父窗口
inherited;
end;
如何在TMyComboBox销毁时清空Items内容?
Destructor Destroy;override;
...Destructor TMyComboBox.Destroy;
begin
Items.Clear;!!!!该句会导致异常,说是MyComboBox1没有父窗口
inherited;
end;
如何在TMyComboBox销毁时清空Items内容?
constructor Create(AOwner: TComponent; AParent: TWinControl);reintroduce;
begin
inherited Create(AOwner);
Self.Parent := AParent;
end;以后这样创建TMyComboBox:
var
cBox: TMyComboBox;
begin
cBox := TMyComboBox.Create(NIL, Form1) //同事赋一个显示组件
end;
这样的话,在Destroy的时候可以保证实例有父窗口。
其实,都销毁了,为什么还要清空那??