問題一:
關閉一個窗口時,在事件onclosequery中添加程序  
if application.messagebox('是否要保存數據',MB_YESNOCANCEL+MB_ICONquestion)=mrcancel
then
(如何不讓窗口關閉,即不進行操作)
問題二:
combobox組件的添加爲何不行。
我用代碼combobox.item.add()添加數據,在程序運行時添加成功,但儅下次啓動程序時,添加的信息又沒了,怎麽解釋,如何讓添加的信息永久的保存于combobox中。
絕對給分!

解决方案 »

  1.   

    if application.messagebox('是否要保存數據',MB_YESNOCANCEL+MB_ICONquestion)=mrcancel
    then
     CanClose:=false;
      

  2.   

    1、if application.messagebox('是否要保存數據',MB_YESNOCANCEL+MB_ICONquestion)=mrcancel
    then
     
    2、将combobox中的信息保存到一个INI文件中,下次程序启动的时候再读出来就行了:
    保存:
    在combobox1的onexit中写
    var
      SYSINI: TINIFile;//需要uses inifiles;
      tmpstr: String;
    begin
      SYSINI := TIniFile.Create(ExtractFilePath(Application.ExeName)+'DB.INI');
      try
        with SYSINI do
        begin
          WriteString('Database', 'ServerName', ServerName);
    //这里需要改一下,具体的你根据你的需要写
          
        end;
      finally
        SYSINI.Free;
      end;
    end;读出来,在form的onactivate中写
    var
      SYSINI: TINIFile;
      ServerName: string;
    begin
      SYSINI := TIniFile.Create(ExtractFilePath(Application.ExeName)+'DB.INI');
      try
        ServerName := SYSINI.ReadString('Database', 'ServerName', '');
      finally
        SYSINI.Free;
      end;
      combobox1.item.add(servername);
    end;
      

  3.   

    1)CanClose:=False;
    2)计设期就加进去,或把写进的东西存进文件中,加载窗体时,从文件中写入。写注册表也行
      

  4.   

    一。
       If (Messagedlg('確定要退出系統?',mtConfirmation,[mbYes,mbNo],0)=mrYes) then
       begin
          canclose:=true;
          application.Terminate;
       end
       else
          canclose:=false;
    二。在設計程序的時候在ComboBox的items屬性中埴上你所需的值
      

  5.   

    1. 设置CanClose := False;
      

  6.   

    你也可以在连接数据库时动态添加。
    combobox.items.clear;
    with query1 do
    close;
    sql.clear;
    sql.add('select * from table1');
    open;
    first;
    while not eof do
    begin
    combobox.items.add(query1.fields[0].asstring);
    next;
    end;