我在combobox1的(TStrings)里加入三行字符 1.'aaa' 2.'bbb' 3.'ccc';如何能实现如下的语句:
if 选中的是行一(或者字符是'aaa') then edit1.text:='1';
if 选中的是行一(或者字符是'bbb') then edit1.text:='2';
if 选中的是行一(或者字符是'ccc') then edit1.text:='3';错误提示(boolean 类型什么的) 是不是combobox不能使用if then 这样的语句
if 选中的是行一(或者字符是'aaa') then edit1.text:='1';
if 选中的是行一(或者字符是'bbb') then edit1.text:='2';
if 选中的是行一(或者字符是'ccc') then edit1.text:='3';错误提示(boolean 类型什么的) 是不是combobox不能使用if then 这样的语句
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
ComboBox1: TComboBox;
Button1: TButton;
Edit1: TEdit;
procedure ComboBox1Change(Sender: TObject);
private
{ Private declarations }
public
procedure AfterConstruction(); override;
end;var
Form1: TForm1;implementation{$R *.dfm}procedure TForm1.AfterConstruction();
begin
inherited AfterConstruction();
ComboBox1.Items.Add('1.aaa');
ComboBox1.Items.Add('2.bbb');
ComboBox1.Items.Add('3.ccc');
ComboBox1.ItemIndex := 0;
ComboBox1Change(ComboBox1);
end;procedure TForm1.ComboBox1Change(Sender: TObject);
begin
Edit1.Text := IntToStr(TComboBox(Sender).ItemIndex + 1);
end;