Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Delphi get android combobox selected item text

I have a combobox that has a lot of items inside and I have to get into a variable the name of the selected item.

var a:string;
begin
 a:=ComboBox1.Text;
end;

This is the way I used for a Delphi VCL application and it works. Here I'm developing with Firemonkey and Android, I haven't the text property.

How can I get the text of the selected item on my combobox?

like image 333
Alberto Rossi Avatar asked Sep 24 '13 20:09

Alberto Rossi


2 Answers

The same way works in FireMonkey as in VCL code - use the TComboBox.Items. TComboBox.ItemIndex tells you which one is currently selected (or allows you to set the selection).

To read:

if ComboBox1.ItemIndex <> -1 then
  ShowMessage(ComboBox1.Items[ComboBox1.ItemIndex]);

To set:

ComboBox1.ItemIndex := 2;
like image 188
Ken White Avatar answered Sep 21 '22 23:09

Ken White


you can access the Selected property to get text :

 if ComboBox1.ItemIndex >= 0 then
    ShowMessage(ComboBox1.Selected.Text);
like image 20
S.MAHDI Avatar answered Sep 17 '22 23:09

S.MAHDI