...
procedure TForm.FormCreate(Sender: TObject);
begin
TuQuery.Close;
TuQuery.SQL.Text := 'SELECT ID, NOMBRE FROM TU_TABLA';
TuQuery.Open;
while not TuQuery.Eof do
begin
ComboBox1.AddItem( TuQuery.FieldByName('NOMBRE').AsString,
TObject(TuQuery.FieldByName('ID').AsInteger) );
TuQuery.Next;
end;
end;
procedure TForm.ComboBox1Change(Sender: TObject);
var
nombre: string;
id: Integer;
begin
if ComboBox1.ItemIndex <> -1 then
begin
nombre := ComboBox1.Items[ComboBox1.ItemIndex];
id := Integer(ComboBox1.Items.Objects[ComboBox1.ItemIndex]);
ShowMessage(Format('%s %d',[nombre, id]));
end;
end;