delphi comboBox
15,132
Solution 1
You find the selected item with:
combobox.ItemIndex; // -1 if none
You can get the value using
combobox.Items[combobox.ItemIndex]
Solution 2
combobox.text will hold the value which was selected
Author by
none
Updated on June 04, 2022Comments
-
none almost 2 years
how does one get the picked value of a combo box from delphi 7
lets say it has items, how does one know which row (item) was picked?
-
David Heffernan over 13 yearsobviously you get an error if you write combobox.Items[combobox.ItemIndex] without checking that combobox.ItemIndex<>-1 first
-
Toby Allen over 13 yearsOne issue here however is if the combobox allows editing the text may not match any of the items, which is worth noting.
-
Haywood Chablowme almost 7 yearssince i have no enough points to comment previous answer i needed to put it as separate answer. Toby's comment actually warns about same thing.