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
Solved

Unable to access Control Events after removing from GroupBox?

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

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 85

Expert Comment

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

791 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