Combobox in firemonkey without using Fdquery

Asked

Viewed 800 times

1

I have a states combobox in my register, where I connect via livebindings with an Fdmemtable to save the data in the database. How could I get the index item of the selected item in the combo?

The only bidirectional Binding I found was Selectedvalue, only it returns the item string and I need the index.

I don’t want to load my combo from an Fdquery or Fdmemtable

I’m using the following code:

ACombo.Items.AddObject(GetPropValue(FListaCombo.Items[I], FCampoDescricao), FListaCombo.Items[I]);

I use RAD Studio XE 10.2

Edited:

Note: My project is in firemonkey (FMX)

Itemindex generates a one-way link

O itemindex gera um link unidirecional

Selectedvalue generates a bidirectional link, only it only returns the text and I want the index (or id)

Já o SelectedValue gera um link bidirecional, só que só retorna o texto e eu quero o index (ou id)

1 answer

2

If it returns the Item String, use the native class function TStrings.

Ex: ComboBoxX.Items.IndexOf('o_que_ele_retornou_string');

See internal IDE documentation: Tstrings - > Indexof.

Note. If the String appears more than once in the List, it will return the index of the first!

Edit.

For manual connection, it should be kept in mind that the "Binding" does not bring all properties, you should select the component in the LiveBindingis Design and press CTRL+N and check the desired property!

  • I don’t know if I explained myself well, but I would like to get the index using livebinds

  • @Matheusribeiro all right, check the answer edition.

  • This CTRL+N procedure I already knew, the problem is that even with this command I could not find a property that is bidirectional that returns the index of the selected item

  • To ItemIndex doesn’t work? which version of Delphi?

  • Good every time Inko with Itemindex is generated a unidentional Binding , only I want a bidirectional. I am using RAD Studio 10.2.2 Tokyo

  • check the question edition

Show 1 more comment

Browser other questions tagged

You are not signed in. Login or sign up in order to post.