Solved

Unable to access Control Events after removing from GroupBox?

Posted on 2013-11-13
4
238 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
  • 3
4 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
Comment Utility
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 85

Expert Comment

by:Mike Tomlinson
Comment Utility
*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
Comment Utility
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 85

Expert Comment

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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Microsoft Reports are based on a report definition, which is an XML file that describes data and layout for the report, with a different extension. You can create a client-side report definition language (*.rdlc) file with Visual Studio, and build g…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

743 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

17 Experts available now in Live!

Get 1:1 Help Now