Solved

Stopping the SelectedIndexChanged Event

Posted on 2007-03-23
1
248 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
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

759 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

22 Experts available now in Live!

Get 1:1 Help Now