Link to home
Start Free TrialLog in
Avatar of Skjori
Skjori

asked on

Event triggered several times at once

Why do the selectedIndexChanged-event on the ListBox trigg four times when I click an item in the list once?
How do I avoid that? Can I use another event?

SOLUTION
Avatar of puranik_p
puranik_p
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Skjori
Skjori

ASKER

I don't think so because the event is not triggered at all before I click the item.
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Set a break point in the event and catch it triggering several times.

Each time you enter break mode, check the Sender object. The Sender object may be different when you get the event when you think you shouldn't be getting it. Sometimes you can check the sender object type and selectively enter your method code based on the sender.

Hmmm, that advice sorta sounds familiar :)

Bob