?
Solved

Stopping the SelectedIndexChanged Event

Posted on 2007-03-23
1
Medium Priority
?
255 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 2000 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

764 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