Hola.
Como te sugiere
iMia, los combos cumplen muy bién la tarea que buscas.
Código Delphi
[-]
...
implementation
procedure LoadComboBox(DS: TDataSet; CB: TComboBox);
begin
DS.DisableControls;
try
DS.First;
CB.Clear;
while not DS.Eof do
begin
CB.AddItem(DS.FieldByName('NOMBRE_PERFIL').AsString,
TObject(DS.FieldByName('CODIGO_PERFIL').AsInteger));
DS.Next;
end;
DS.First;
finally
DS.EnableControls;
end;
end;
function GetProfileCode(CB: TComboBox): Integer;
begin
Result := Integer(CB.Items.Objects[CB.ItemIndex]);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Tu_DataSet.Open;
LoadComboBox(Tu_DataSet, ComboBox1);
end;
procedure TForm1.ComboBox1Change(Sender: TObject);
var
cb: TComboBox;
code: Integer;
begin
cb := TComboBox(Sender);
code := GetProfileCode(CB);
ShowMessage(Format('%s: %d',[cb.Items[cb.ItemIndex], code]));
end;
Saludos