Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Unable to access Control Events after removing from GroupBox?

Posted on 2013-11-13
4
Medium Priority
?
248 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

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…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

604 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