Le 7/01/2015 07:49, Marc Santhoff a écrit :
Hi,
it has been a very long time since I've programmed GUIs. I have
forgotten how to fill a ListBox without having the event handler
OnSelectionChange executed.
I've had the same problem for years, until I "invented" my method:
- fill in the two events OnEnter and OnExit for the control
- generate the code for the OnSelectionChange event and drop immediately
the event in the component explorer
- manually fill in the following code in the three envents:
TMyForm.MyComponentEnter(Sender: TObject);
begin
MyComponent.OnSelectionChange := MyComponentSelectionChange;
// do the same for all other events you want to drive
end
TMyForm.MyComponentSlectionChange(Sender: TObject; ...);
begin
// do whatver to do when the event fires
end
TMyForm.MyComponentExit(Sender: TObject);
begin
MyComponent.OnSelectionChange := nil
end
Of course you can control any firing event using the OnEnter and OnExit
events of the control. This allows the program to fire events only when
the user enters the control.
I think that GUI's lack a control property wich indicates whether the
events should always fire or fire only when the user enters the control.
Antonio.
I have tried (Un)LockSelectionChange on the list, setting ItemIndex to
-1, all in the forms create method. I've tried using add() or assign()
on the listbox's Items, nothing helps.
The wiki on TListBox doesn't say anything on this topic, neither does
the LCL help document.
How can it be done?
---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel
antivirus Avast.
http://www.avast.com
--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus