Solved

Stopping the SelectedIndexChanged Event

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.

831 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