procedure TForm1.Button1Click(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.ComboBox1Change(Sender: TObject);
begin
edit1.Text := string(combobox1.Items.Objects[combobox1.ItemIndex]);
end;
ComboBox的DataValue值
Delphi中ComboBox操作示例
最新推荐文章于 2024-04-12 11:41:50 发布
博客展示了Delphi中两个过程代码。在Button1Click过程里,清空ComboBox并添加城市及对应编号;在ComboBox1Change过程中,将所选项目的编号显示在Edit控件中,主要涉及字符串操作和控件交互。
2万+





