Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TListbox - OnChangeEvent does not fire reliable on multiselect

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.

like image 242
Rynardald Avatar asked Jan 28 '26 17:01

Rynardald


1 Answers

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.

like image 70
LU RD Avatar answered Jan 31 '26 09:01

LU RD



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!