关于ComboBox控件的问题

reanna 2003-09-11 11:26:53
想通过选择的item作为判断条件做下一步的操作,
if item[0] 。。。
else item[1]。。。
但是好像没有Selected属性
不知delphi如何判断Combobox里的项目?
谢谢!
...全文
46 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
ysycrazy 2003-09-11
  • 打赏
  • 举报
回复
procedure TForm1.ComboBox1Click(Sender: TObject);
begin
if ComboBox1.ItemIndex=0 then
ShowMessage('中秋节');
end;
ysycrazy 2003-09-11
  • 打赏
  • 举报
回复
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
if ComboBox1.Text='中秋节' then
ShowMessage('我要吃月饼!')
else
ShowMessage('没有别的选则.......');

end;
WWWWA 2003-09-11
  • 打赏
  • 举报
回复
combobox1.text
combobox1.itemindex 均可
WWWWA 2003-09-11
  • 打赏
  • 举报
回复
combobox1.text
combobox1.itemindex 均可
WWWWA 2003-09-11
  • 打赏
  • 举报
回复
combobox1.text
combobox1.itemindex 均可
hongqi162 2003-09-11
  • 打赏
  • 举报
回复
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;
hhzqf1980 2003-09-11
  • 打赏
  • 举报
回复
itemindex表示:
-1,没有选择,
0,表示第一
1,表示第二
hongqi162 2003-09-11
  • 打赏
  • 举报
回复
style属性设成csDropDownList

判断它的text属性
jianghuxiaozi 2003-09-11
  • 打赏
  • 举报
回复
itemindex
angle097113 2003-09-11
  • 打赏
  • 举报
回复
他的顺序从0 开始的
combobox.itemindex[]就可以的了
jinjintalk 2003-09-11
  • 打赏
  • 举报
回复
procedure TForm1.ComboBox1Change(Sender: TObject);
begin
case combobox1.itemindex of
0:begin
你想做什么
end;
1:begin
你想做什么
end;
......
end;
end;

combobox里的第一项是1,第二项是2,依次

雨后阳光2000 2003-09-11
  • 打赏
  • 举报
回复
itemindex:表示ComboBox1中Items里的各项的序号(从0开始排序)
ComboBox1.Items.Strings[ComboBox1.ItemIndex];//表示combobox1中当前选择的项的值(itemindex表示选择的序号)等于combobox1.text;
IORILI 2003-09-11
  • 打赏
  • 举报
回复
itemindex
haoguozhong 2003-09-11
  • 打赏
  • 举报
回复
同soft_fans
ComboBox1.Items.Strings[ComboBox1.ItemIndex];
lemon_wei 2003-09-11
  • 打赏
  • 举报
回复
ItemIndex:
-1:没有选择任何项
0:选中第一项
1:选中第二项
2:选中第三项
.
.
.依此类推

ComboBox1.Items.Strings[ComboBox1.ItemIndex];表示取选中项的值

5,386

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧