VCL组件ComboBoxEx的TEXT属性如何读取文本文件的内容如果不存在还会自动建立文件ComboBoxEx

解决方案 »

  1.   

    var mystring :TString;
    procedure Tmakefile.makefileclick(Sender:Tobject)
    begin
    mystring:=TString.Create(Self);
    mystring:='c:\read.txt';
    If not fileExists(mystring) then
    ComboBox1.Text:=Memo1.Text;
    SaveDialog.Execute;
    SaveDialog.FileName:='read'+'.txt'
    Memo1.Lines.SaveToFile(SaveDialog1.FileName);
    else
    Memo1.Lines.LoadFromFile(mystring);
    ComboBox.Text:=Memo1.Text;
    end;
    基本实现方法把要读写的文件给一个实例变量,把文件内容先装入MEMO。再把MEMO装入comboBox.text中。至于直接创建我还不会。呵。。我是写的要是无此文件。自动提示保存一个。
      

  2.   

    第:7条反了应该是:Memo1.Text:=ComboBox1.Text;
      

  3.   

    //动态添加
    if key=char(13) then
       with combobox2 do
        if (text<>'') and (items.IndexOf(text)<0) then
            items.Add(text);
    可是退出后我不知道如何保存
      

  4.   

    var mystring :TString;
    procedure Tmakefile.makefileclick(Sender:Tobject)
    begin
    mystring:=TString.Create(Self);
    mystring:='c:\read.txt';
    If not fileExists(mystring) then
    Memo1.Text:=ComboBox1.Text;
    SaveDialog.Execute;
    SaveDialog.FileName:='read'+'.txt'
    Memo1.Lines.SaveToFile(SaveDialog1.FileName);
    else
    Memo1.Lines.LoadFromFile(mystring);
    ComboBox.Text:=Memo1.Text;
    end;
    在系统自动实现加载如何实现,起码makefileclick的makefile要声明吗?click在那里控件的什么事件效果最好,
      

  5.   

    if key=char(13) then
       with combobox2 do
        if (text<>'') and (items.IndexOf(text)<0) then
            items.Add(text);
            SaveDialog.Execute;
            SaveDialog.FileName:='read'+'.txt'
           Memo1.Lines.SaveToFile(SaveDialog1.FileName);
    可以了吧