ComboBox1.Items.Clear; s:= '1001'; //ComboBox1.Items.Add('1'); ComboBox1.Items.AddObject('1',TObject(s) ); s:='2001'; //ComboBox1.Items.Add('2'); ComboBox1.Items.AddObject('2',TObject(s) ); s:='3001'; //ComboBox1.Items.Add('3'); ComboBox1.Items.AddObject('3',...
ComboBox1.Items.Clear; s:= '1001'; //ComboBox1.Items.Add('1'); ComboBox1.Items.AddObject('1',TObject(s) ); s:='2001'; //ComboBox1.Items.Add('2'); ComboBox1.Items.AddObject('2',TObject(s) ); s:='3001'; //ComboBox1.Items.Add('3'); ComboBox1.Items.AddObject('3',...
你可以直接为 ComboBox 的 Text 属性赋值,这将在 ComboBox 中显示指定的文本。如果 ComboBox 的 Style 属性设置为 csDropDown 或csSimple,则用户还可以编辑这个文本。 delphi ComboBox1.Text := '指定的文本'; 设置ItemIndex 属性: 通过设置 ItemIndex 属性,你可以选择 ComboBox 中已经存在的某个项目。Item...
ComboBox1.Items.AddObject('客户ID',TObject(A_Code)); A_Value:=string(ComboBox1.Items.Objects[ComboBox1.ItemIndex]); 上面的情况在一般下使用是可以的。但是当A_Code不是直接赋值,而是通过其他途径,比如数据库中取出或者其他任意函数构成的,比如A_Code:='a'+'b';这样就得不到A_Value了,或者是得到...
procedure TMycbb.Additem(ADOQuery1: TADOQuery;Asql:string; ccb: TComboBox;var ss:Tarr); var i: Integer; s: string; begin ccb.items.clear(); s := 'bd'; ccb.items.addobject('不定', Tobject(s)); ADOQuery1.close(); ADOQuery1.SQL.Text :=Asql; ...
varpBH:pInteger;...while not 记录集.eof dobeginnew(pBH);pBH^:=编号字段的值;combobox.items.addobject(姓名字段的值,TObject(pBH))记录集.next();end;...在读combobox的时候:编号:=pInteger(combobox.items.objects[combobox.itemindex])^;可以生成这样的 项 编号+'$'+ 姓名然后用的时候...
Memo1.Lines.Assign(ComboBox1.Items); 要注意的是使用了Assign方法后,目标字符串列表中原有的字符串会全部丢失。 同对象关联 前面说了我们可以将字符串同对象绑定起来,我们可以使用AddObject或者InsertObject方法向列表添加同字符串关联的对象,也可以通过Objects属性直接将对象同特定位置的字符串关联。此外TStrings类还提...
combobox1.Items.AddObject('值1',TObject(strnew(PChar(‘值2’)));//第2个参数也是指针来的 应用如下(str1和str2分别得到当前选中节点的值1和值2)Str1:=combobox1.Items.Strings[combobox1.itemindex];str2:=string(combobox1.Items.Objects[combobox1.ItemIndex]);--- 另外,除了能利用...
文件控件的方法、事件基本是从ListBox和ComboBox中继承的。但FileListBox 中有一个ApplyFilePath方法很有用,我们将在后边给出其用法。 6.3.2 文件名浏览查找系统的设计思路 作为文件控件的应用实例,我们开发了一个简单的文件名浏览查找系统。这个系统可用于文件名的显示,把选中的文件写入列表框,并能按文件编辑框...
Delphi_ComboBox_AddObject_Items_Values unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, DB, ADODB; type TForm1 = class(TForm) cmbbzxh: TComboBox; bbtnShowName1: TBitBtn;...