赋值 ComboBox.Properties.Items.Clear; ComboBox.Properties.Items.BeginUpdate; adoquery.first; while not adoquery.Eof do begin ComboBox.Properties.Items.AddObject(adoquery.FieldByName('Name').AsString,Pointer(adoquery.FieldByName('BH').AsInteger)); adoquery.Next; end; ComboBox.Properties.Items.EndUpdate;取值: Result := Integer(ComboBox.Properties.Items.Objects[ComboBox.ItemIndex]);
有一个方法 if adotable.locate('name',combobox.text,[]) then 取出编号后台用=adotable.fieldbyname('bh').asinteger;
你可以用cxLookupComboBox控件可以实现
procedure TMAIN.ComboChange(Sender: TObject); Var CurrRecNo :Integer; begin CurrRecNo:=DataSet.RecNo; DataSet.MoveBy(CmbNsrxx.ItemIndex+1-CurrRecNo); end;
procedure TMAIN.ComboBoxChange(Sender: TObject); Var CurrRecNo :Integer; begin CurrRecNo:=DataSet.RecNo; DataSet.MoveBy(ComboBox.ItemIndex+1-CurrRecNo); end;
combobox1.items.AddObject('xxx',Pointer(IntValue)) and selvalue = Integer(combobox1.items.Objects[combobox1.ItemIndex])
ComboBox.Properties.Items.Clear;
ComboBox.Properties.Items.BeginUpdate;
adoquery.first;
while not adoquery.Eof do
begin
ComboBox.Properties.Items.AddObject(adoquery.FieldByName('Name').AsString,Pointer(adoquery.FieldByName('BH').AsInteger));
adoquery.Next;
end;
ComboBox.Properties.Items.EndUpdate;取值:
Result := Integer(ComboBox.Properties.Items.Objects[ComboBox.ItemIndex]);
if adotable.locate('name',combobox.text,[]) then
取出编号后台用=adotable.fieldbyname('bh').asinteger;
Var
CurrRecNo :Integer;
begin
CurrRecNo:=DataSet.RecNo;
DataSet.MoveBy(CmbNsrxx.ItemIndex+1-CurrRecNo);
end;
Var
CurrRecNo :Integer;
begin
CurrRecNo:=DataSet.RecNo;
DataSet.MoveBy(ComboBox.ItemIndex+1-CurrRecNo);
end;
and
selvalue = Integer(combobox1.items.Objects[combobox1.ItemIndex])
TCCC = class
BH:integer;
name:string;
end;OBJ:= TCCC.Create;
OBJ.BH:=...
OBJ.name:=...
combobox1.item.addObject(OBJ.name,OBJ);
前台当然显示:OBJ.name
后台取的时候 bh:= TCCC(combobox1.object[combobox1.itemindex]).BH;
另外,你给的问题实在是太寒蝉了鄙视一下!