控件 TComponent 继承,TMy控件
private
  FListView:TListView;
published
  property ListView:TListView read FListView write FListView;
end;放到界面上,设置一个 ListView后,如果将 ListView 直接删除或Ctrl+X 掉,控件就出错?
怎么解决呢????????

解决方案 »

  1.   

    你是不是对listview有相应的代码
      

  2.   

     找到原因了。
    要加一个
    procedure  Notification(AComponent: TComponent; Operation:  TOperation); override;
    begin
      inherited;
      if opRemove=Operation  then //opInsert, opRemove
      begin
        Showmessage(AComponent.ClassName );
        FListView:=nil;
      end;
    end;
      

  3.   

      if (AComponent=FListView) and (Operation=opRemove) then
        FListView:=nil;建议而已。
    不过,既然解决了,散分吧。