procedure TForm1.ComboBox1Change(Sender: TObject);
begin
  if ComboBox1.Text:='' then
    ComboBox1.Text:=ComboBox1.Items.String[1];
end;
怎么改?

解决方案 »

  1.   

    procedure TForm1.ComboBox1Change(Sender: TObject);
    begin
      if ComboBox1.Text  ='' then
        ComboBox1.Text:=ComboBox1.Items.String[1];
    end;
      

  2.   

    if ComboBox1.Text='' then
      

  3.   

    注意是 if Combobox1.Text = '' then 不是 if Combobox1.Text := '' then
      

  4.   

    不行,错误信息是:[Error] Unit1.pas(28): Type of expression must be BOOLEAN
    [Error] Unit1.pas(29): Identifier expected but 'STRING' found
    [Fatal Error] Project2.dpr(5): Could not compile used unit 'Unit1.pas'
      

  5.   

    procedure TForm1.ComboBox1Change(Sender: TObject);
    begin
      if (ComboBox1.Text = '') then
        ComboBox1.Text:=ComboBox1.Items.String[0];
    end;
      

  6.   

    [Error] Unit1.pas(28): Type of expression must be BOOLEAN
    就是说if判断语句不是个boolean,按大家说的改应该没错阿[Error] Unit1.pas(29): Identifier expected but 'STRING' found
    ComboBox1.Text:=ComboBox1.Items.String[1];改成
    ComboBox1.Text:=ComboBox1.Items.Strings[1];//注意加了s[Fatal Error] Project2.dpr(5): Could not compile used unit 'Unit1.pas'
    解决了上述两个错误就可以了
    这段代码有什么用哈~~
      

  7.   


    if (ComboBox1.Text = '') then
        ComboBox1.Text:=ComboBox1.Items[0];