如果是固定的,可以直接设置Items.
否则只能保存到文件或注册表了。

解决方案 »

  1.   

    onshow()里写;
    还有是savetofile到文件里;+loadfromfile
      

  2.   

    你用 DBCombobox1 ,就可以保存到数据库啊!
      

  3.   

    可以保存在ini文件里 combabox里的项目太多会造成注册表太大
    先在 uses 里声明 IniFiles;
    然后 IniF:TIniFile;
    const cb1 = '追加';
          zj1 = '行数';  procedure TMain.FormCreate(Sender: TObject);
    var fst :String;
    begin
       fst := Copy (Application.ExeName, 1, Pos('.', Application.ExeName) -1) + '.ini';//设置Ini文件名为主程序名+Ini
       inif := TIniFile.Create(fst);//创建Ini文件
       ReadIniFile;
    end;procedure TMain.FormDestroy(Sender: TObject);
    begin
        WriteIniFile;
        inif.UpdateFile;
        inif.Free;
    end;procedure TMain.ReadIniFile;
    var i,j : integer;
    begin
     with Inif do
        begin  
        J:= ReadInteger(cb1,zj1,0);
       for I := 0 to J-1 do
         begin
           combobox1.items.Add(ReadString(cb1, IntToStr(I), ''));//读入历史
         end;
         end;   
    end;procedure tmain.writeinifile;
    var i : integer;
    begin
        with inif do
         begin
          WriteInteger(cb1,zj1,combobox1.items.Count);
          for I := 0 to combobox1.items.Count-1 do
           begin
              WriteString(JiShi, IntToStr(I), combobox1.items.Strings[I]);//写入纪录
           end;
          end;
     
    end;
      

  4.   

    关于注册表的一些操作
    User Registry;
        var
        RegF:TRegistry;
      begin
         RegF:=TRegistry.Create;
         RegF.RootKey:=HKEY_LOCAL_MACHINE;
          try
            RegF.OpenKey
                  Regf.WriteString();//可以根据需要采用其他函数
         except
         End;
         RegF.Close;
         RegF.Free;
      end;
      

  5.   

    不好意思,应该是regf.closeKey;
    另外,给你一个实际例子:
    RegF:=TRegistry.Create;
    RegF.RootKey:=HKEY_LOCAL_MACHINE;
    try
        RegF.OpenKey('SOFTWARE\Microsoft\Windows\CurrentVersion\Run',True);
        RegF.WriteString('Interbase Server','"D:\Program Files\Borland\IntrBase\BIN\ibserver.exe"');
    except
    End;
    RegF.CloseKey;
    RegF.Free;
      

  6.   

    这样吧,包你满意:
    其实你那个不用你自己去保存的,因为数据库里面已经有了
    你只需要在合适的时候(反正在数据连接完成后,用户操作前:)
    从数据库里面把所有的相关值取出来就行了好像可以用TLookupComboBox(是这样写的吗?记不清楚了:)如果是SQL语句: Select distinct xx from yy 然后一条一条加到列表中