控件的使用问题求解(一)
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
DateTimePicker1.time:=time;
DateTimePicker2.time:=time;
DateTimePicker3.time:=time;
DateTimePicker4.time:=time;
DateTimePicker5.time:=time;
DateTimePicker6.time:=time;
DateTimePicker7.time:=time;
DateTimePicker8.time:=time;
DateTimePicker9.time:=time;

end;可否简单写,如果100个,岂不累死
*************************************************************************控件的使用问题求解(二)
10个EDIT与1个MEMO,要求将10EDIT中写有东西的EDIT列在MEMO中,如果某EDIT中没有写东西,则不列出来。
MEMO.LINE.ADD(EDIT1.TEXT+EDIT2.TEXT+...EDIT10.TEXT)
请问如何判断后EDIT中没有东西,并不写出来? 

解决方案 »

  1.   

    一、
    var
     i:integer;
    begin
     for i:=self.ComponentCount-1 do
      if (Components[i] is TDateTimePicker) then
       (Components[i] as TDateTimePicker).time:=time;
    end;二、
    EDIT里没有东西,当然不会写出来呀。还是我理解错了?
      

  2.   

    if Edit1.text='' then
    可判断有没有东西,两个引号间无间隔
      

  3.   

    是我没有说清楚
    控件的使用问题求解(二)
    10个LABEL、10个EDIT与1个MEMO,要求将10EDIT中写有东西的EDIT列在MEMO中,如果某EDIT中没有写东西,则不列出来。
    MEMO.LINE.ADD(LABEL1.CAPTION+EDIT1.TEXT+LABEL2.CAPTION+EDIT2.TEXT+...LABEL10.CAPTION+EDIT10.TEXT)
    请问如何判断后EDIT(n)中没有东西,LABLEn.CAPTION与EDITn.TEXT不写出来. 
      

  4.   

    如果是一个Label对应一个Edit,控件面版Additional中有一种LabeledEdit控件正适合。它的LabelPosition属性可以设置Label在Edit周围的位置。
    var i:integer
    begin
     for i:=0 to self.ComponentCount-1 do
      if (self.Components[i] is TLabeledEdit) then
       if (self.Components[i] as TLabeledEdit).text <> '' then
         Memo1.Lines.Add((self.Components[i] as TLabeledEdit).EditLabel.Caption+(self.Components[i] as TLabeledEdit).text);
    end;
      

  5.   

    var
      str:string;
    begin
      str:='';
      for i:=0 to self.ComponentCount-1 do
      if (Components[i] is Tedit) then
      if  (((Components[i] as Tedit).text:<>'') or ((Components[i] as Tedit).text:<>null)) then 
    str:=str+(((Components[i] as Tedit).text;
      Memo1.Lines.Add(str);
    end;
      

  6.   

    是我没有说清楚
    控件的使用问题求解(二)
    10个LABEL、10个EDIT与1个MEMO,要求将10EDIT中写有东西的EDIT列在MEMO中,如果某EDIT中没有写东西,则不列出来。
    MEMO.LINE.ADD(LABEL1.CAPTION+EDIT1.TEXT+LABEL2.CAPTION+EDIT2.TEXT+...LABEL10.CAPTION+EDIT10.TEXT)
    请问如何判断后EDIT(n)中没有东西,LABLEn.CAPTION与EDITn.TEXT不写出来. 
      

  7.   

    可以设置一个变量str1
    for i:=0 to self.ComponentCount-1 do
      if (Components[i] is Tedit) then
      if  (((Components[i] as Tedit).text<>'') or ((Components[i] as Tedit).text<>null)) then 
    str1:=str+(((Components[i] as Tedit).text;
      Memo1.Lines.Add(str1);
    end;