Solved

Stopping the SelectedIndexChanged Event

Posted on 2007-03-23
1
253 Views
Last Modified: 2008-01-09
I am updating a combo box during a form load which is firing off the SelectedIndexChanged event, but I do not want it to fire this event at this stage. Is there a way to stop this?

Regards,

Josh
0
Comment
Question by:supersuny2k
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 17

Accepted Solution

by:
ZeonFlash earned 500 total points
ID: 18779401
There are several methods you can use to get around this problem.

1.  You can always remove the event handler and add it back again after loading.  This isn't necessarily the "best" way of doing things, considering the problem that occurs if the loading stops before adding the event handler back.

RemoveHandler Combobox1.SelectedIndexChanged, AddressOf Combobox1_SelectedIndexChanged
.
.
AddHandler Combobox1.SelectedIndexChanged, AddressOf Combobox1_SelectedIndexChanged

2.  You can create a class variable along the lines of "IsLoading" that you set to True while the form is loading and False when it's done.  Then at the top of your SelectedIndexChanged event, you check the flag and continue on if not loading:

     Private IsLoading As Boolean = False

      Private Sub Combobox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Combobox1.SelectedIndexChanged
     If IsLoading Then Exit Sub
      .
      .

            End Sub
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

691 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