TListbox - OnChangeEvent does not fire reliable on multiselect

397 Views Asked by At

I'm using XE7 and FMX.

My problem is that the OnChange-Event for TListbox works not correctly with multiselect (it does not fire everytime when a change occured).

Steps to reproduce:

  • Create a FMX-application and add a TListbox to his form.
  • Add items to this listbox.
  • Set 'MultiSelectStyle' of Listbox to 'default'.
  • Handle the OnChangeEvent (set a breakpoint or do something ...).
  • Now run the project and click on the first Item -> OnChange is executed.
  • But if first item is clicked again the OnChange will not be executed.

Can tell me somebody how I can fix this, so that everytime when a the selection changes I get a event.

1

There are 1 best solutions below

2
LU RD On

From documentation FMX.ListBox.TCustomListBox.OnChange:

Occurs when the selection in the list box changes. Write an OnChange event handler to take specific action immediately after a new item or items are selected in the list box.

Use the OnClick or OnItemClick event instead to monitor when the user reselects the same selection. And keep the OnChange handler for all new selections.