Solved

Unable to access Control Events after removing from GroupBox?

Posted on 2013-11-13
4
244 Views
Last Modified: 2013-11-14
I'm having a problem accessing my control events that were contained inside a GroupBox. I recently removed all the controls from a GroupBox and just placed them on the form but I then deleted the GroupBox. The Control Events are present in the Form, however, if I double-click on one of the controls now, it creates a new instance of the Event and adds a _1 to the end of the Event Name. What's happening here?

Thanks
0
Comment
Question by:BlakeMcKenna
[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
  • 3
4 Comments
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 39646709
When you cut and paste controls on the Form, the IDE removes the `Handles xxx.yyy" clause from the existing handler.

For instance, if you had Button1 with its Click() handler:
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click

    End Sub

Open in new window


Then you cut and pasted Button1 to somewhere else on the Form, you'd end up with:
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs)

    End Sub

Open in new window

Note how the "Handles Button1.Click" clause at the end of the method declaration is now missing.


To fix this, you need to "re-wire" up Button1's Click Handler:
(1) Select Button1.
(2) In the Properties Pane, bottom right by default, click on the "Lightning Bolt" Icon.
(3) Find the "Click" entry and change the DropDown to the right back to "Button1_Click".

This can also be fixed by manually typing back in the correct Handles clause after each method.
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 39646712
*One final note, this doesn't happen if you DRAG the controls out of the GroupBox and onto the Form (or into a different container).

So if you want to avoid this in the future, don't CUT and PASTE, but instead DRAG.  =)
0
 

Author Comment

by:BlakeMcKenna
ID: 39647833
Believe it or not I actually figured that out shortly after I submitted this question. But thank you for validating this! I'm assuming if you just copy the control to another location on the page, it doesn't remove the Handles clause?
0
 
LVL 86

Expert Comment

by:Mike Tomlinson
ID: 39648000
Right, copying won't remove the Handles clause.
0

Featured Post

Enroll in June's Course of the Month

June’s Course of the Month is now available! Experts Exchange’s Premium Members, Team Accounts, and Qualified Experts have access to a complimentary course each month as part of their membership—an extra way to sharpen your skills and increase training.

Question has a verified solution.

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

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
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…

724 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