如:1.edit1
    2.combobox1
    3.memo1
怎么样才能把他们的值存入stringslist里啊
存到列表的顺序不能变
要怎么实现啊。谢谢!

解决方案 »

  1.   

    procedure TForm1.FormCreate(Sender: TObject);var
      MyList: TStringList;
      i,Index: Integer;
    begin
      MyList := TStringList.Create;
      try
        MyList.Add('edit1.text');
       for i:=0 to combobox1.Items.Count-1 do
        MyList.Addcombobox1.Items[i]);    MyList.Add(memo1.text);    MyList.Sort;   { Find will only work on sorted lists! }
        if MyList.Find('Flowers', Index) then
        begin
          ListBox1.Items.AddStrings(MyList);
          Label1.Caption := 'Flowers has an index value of ' + IntToStr(Index);
        end;
      finally
        MyList.Free;
      end;
    end;
      

  2.   

    qhf503(和风) 谢谢我的意思是要用循环怎么做呢。。要一种控件的话用component就可以了。要是多种不同类型的要怎么办啊。。要10个以上呢。。谢谢!
      

  3.   

    procedure TForm1.ClearText(AControl:TWinControl);
    var
      I: Integer;
    begin
      for I := 0 to AControl.ControlCount - 1 do    // Iterate
      begin
           //  MyList 上面创建的,其余的类似
          if AControl.Controls[i] is TEdit then
          begin
            MyList.Add((AControl.Controls[i] as TEdit).Text);       
          end;
          if AControl.Controls[i] is TPanel  then
          begin
            ClearText(AControl.Controls[i] as TPanel);
          end;
       end;
    end;
    procedure TForm1.btn1Click(Sender: TObject);
    begin
      ClearText(self);
    end;