Solved

Unable to access Control Events after removing from GroupBox?

Posted on 2013-11-13
4
243 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

733 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