Search code examples
delphicomboboxdevexpressvcl

Get selected TObject value from ComboBox


How get TObject value from selected TcxComboBox eg. For BMW => 2 or MERCEDES => 3

myTcxComboBox.Properties.Items.AddObject('AUDI',TObject(1));
myTcxComboBox.Properties.Items.AddObject('BMW',TObject(2));
myTcxComboBox.Properties.Items.AddObject('MERCEDES',TObject(3));

Solution

  • If you add an integer as an object, what you have to do is only casting that object to integer;

    selected := NativeInt(myTcxComboBox.Properties.Items.Objects[myTcxComboBox.ItemIndex]);