procedure TForm1.ComboBox1Change(Sender: TObject); begin if combobox1.Text='1' then begin application.MessageBox('1','',mb_ok); end else if combobox1.Text ='2' then begin application.MessageBox('2','',mb_ok); end else begin application.MessageBox('other','',mb_ok); end; end;
combobox1.text combobox1.itemindex 均可
combobox1.text combobox1.itemindex 均可
combobox1.text combobox1.itemindex 均可
procedure TForm1.ComboBox1Change(Sender: TObject); begin if ComboBox1.Text='中秋节' then ShowMessage('我要吃月饼!') else ShowMessage('没有别的选则.......');end;
procedure TForm1.ComboBox1Click(Sender: TObject); begin if ComboBox1.ItemIndex=0 then ShowMessage('中秋节'); end;
-1,没有选择,
0,表示第一
1,表示第二
begin
if combobox1.Text='1' then
begin
application.MessageBox('1','',mb_ok);
end
else if combobox1.Text ='2' then
begin
application.MessageBox('2','',mb_ok);
end
else
begin
application.MessageBox('other','',mb_ok);
end;
end;
combobox1.itemindex 均可
combobox1.itemindex 均可
combobox1.itemindex 均可
begin
if ComboBox1.Text='中秋节' then
ShowMessage('我要吃月饼!')
else
ShowMessage('没有别的选则.......');end;
begin
if ComboBox1.ItemIndex=0 then
ShowMessage('中秋节');
end;
-1:没有选择任何项
0:选中第一项
1:选中第二项
2:选中第三项
.
.
.依此类推ComboBox1.Items.Strings[ComboBox1.ItemIndex];表示取选中项的值
ComboBox1.Items.Strings[ComboBox1.ItemIndex];
ComboBox1.Items.Strings[ComboBox1.ItemIndex];//表示combobox1中当前选择的项的值(itemindex表示选择的序号)等于combobox1.text;
begin
case combobox1.itemindex of
0:begin
你想做什么
end;
1:begin
你想做什么
end;
......
end;
end;combobox里的第一项是1,第二项是2,依次
combobox.itemindex[]就可以的了