Event triggered several times at once

Posted on 2005-05-12
Last Modified: 2012-05-05
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?

Question by:Skjori
    LVL 14

    Assisted Solution

    I think, in your code your are changing th selection of the listbox which causes the event to trigger several times.

    Author Comment

    I don't think so because the event is not triggered at all before I click the item.
    LVL 96

    Accepted Solution

    You can put a break point in the event handler, and when it reaches that point, look in the Call Stack, and find out where it is being called from in each of the four cases.

    LVL 10

    Assisted Solution

    if this is app you could have declared the OnSelectedIndexChanged event in the html tab of the control and in the codebehind with an add handler method.
    if the language is VB, check also the event procedure and look for an "Handles YourDropDownName.OnSelectedIndexChanged" text in the declaration of the procedure
    LVL 8

    Expert Comment

    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.

    LVL 96

    Expert Comment

    by:Bob Learned
    Hmmm, that advice sorta sounds familiar :)


    Featured Post

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
    In my previous article ( we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now