说的简单一点combobox1里有3个item:1;2;3.
还有一个是edit1,一个button1.
当combobox1里选中1并clickbutton1 edit1.text显示one
选中2并clickbutton1 edit1.text显示two
选中3并clickbutton1 edit1.text显示three
没选并clickbutton1 edit1.text显示错误
怎么做比较好。听说用
var
ID:TStringList;比较好。我不知道怎么做最简便。
请大家给出关键代码。谢谢。
还有一个是edit1,一个button1.
当combobox1里选中1并clickbutton1 edit1.text显示one
选中2并clickbutton1 edit1.text显示two
选中3并clickbutton1 edit1.text显示three
没选并clickbutton1 edit1.text显示错误
怎么做比较好。听说用
var
ID:TStringList;比较好。我不知道怎么做最简便。
请大家给出关键代码。谢谢。
解决方案 »
- 来分了!谁帮我搞定Richedit中被选字符大小写转换这个小问题的,重赏!
- thread 下面再建立 子thread的问题
- 发现delphi一个很有意思的现象
- 注册成功,试试功能
- 请高手修正, 正尝试编写一个类似TLabeledEdit的聚合控件
- 问一个TDBChart的问题,关于Onmousewheel。
- 有一很奇怪的查询结果。。。。想了N天,没有结果,请帮忙看看。
- 遇到一个难题,请高手帮忙解决!!--------------------在线等待!!!!!!!!
- bde与odbc在使用上有什么不同?我觉得使着没什么分别呀。
- 没办法了,请教了~
- 那儿有详细的SQL命令的介绍?
- 返回字符的ascii的函數是什麼?
var lst:TStringList;
begin
lst:=TStringList.create;
lst.text:=combox1.text;
showmessage(lst.strings[i]);
combox1.text=lst.text;
lst.free
end;
procedure button1(sender :Tobject);
var i:integer;
begin
test(i);
end;
大概就这样吧
为什么是这样?
这样我还不如edit1.text:=combobox1.text来的方便。
关键是combobox1的内容与要edit1显示的内容是不同的。
begin
if combobox1.itemindex=0 then
edit1.text:='one';
if combobox1.itemindex=1 then
edit1.text:='two';
if combobox1.itemindex=2 then
edit1.text:='three';
end;
begin
case combobox1.ItemIndex of
0: edit1.Text :='one';
1: edit1.Text :='two';
2: edit1.Text :='three';
else
edit1.Text :='error';
end;
end;
wind8bell(风之铃)
的方法是我现在用的,还有什么更简便的方法吗?
procedure TForm1.FormCreate(Sender: TObject);
var
s : string;
begin
combobox1.Clear;
s := '01';
combobox1.Items.AddObject('北京',TObject(s));
s := '02';
combobox1.Items.AddObject('天津',TObject(s));
s := '03';
combobox1.Items.AddObject('上海',TObject(s));end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if combobox1.ItemIndex=-1 then begin
edit1.Text:='error';
exit;
end;
edit1.Text := string(combobox1.Items.Objects[combobox1.ItemIndex]);
end;
Info=array[0..3] of string=('One','two','three','error');procedure TForm1.Button1Click(sender:TObject);
begin
if ComboBox1.ItemIndex<0 then
Edit1.Text:=Info[4]
else
Edit1.Text:=Info[ComboBox.ItemIndex];
end;