我覆盖了TCombobox的 destructor Destroy;  destructor Destroy ;override;   procedure TCombobox1.Destroy;
   begin
     if (not (csDesigning in State)) and (Items.Count > 0) then
        Items.SaveToFile('C:\S.txt');
   end ;
   但是,执行时报错 xxx no parent window ???
   网高手解决,,, 谢谢

解决方案 »

  1.   

    begin
      if (not (csDesigning in State)) and (Items.Count > 0) then
         Items.SaveToFile('C:\S.txt');
      inherited;  //加上这句试试
    end ;
      

  2.   

    直接在ondestroy 里面写:
    combobox1.Items.SaveToFile('c:/test.txt'); 
    不可以吗
      

  3.   

    十分感谢你们的 答复:
       我按照 Kevin_Lmx(繁华阅尽)  的做了(嘿嘿 不好意思忘了 Inherited),仍然不行具体报错的
    信息为:
       EInvalidOperation with message 'Control 'MRCombobox1' has no parent window
      我的本意时,自己重构一个TComobox 组件类,改组件类能够在即将被释放时将自身的Items 保存
    到文件中  还望大家多多帮组
      

  4.   

    to : metal11516580(金属狂人)
        应该不会吧,如果能够触发 Destroy 析构函数,一定时已经创建了实例