Home All Groups Group Topic Archive Search About

buttons stopped working

Author
19 Sep 2006 2:26 PM
Dave Cullen
I did a cut & paste of some button controls on one of my forms and now
the button procedures don't get called when the buttons are pushed.
Somehow dotnet has disassociated the buttons with their previous code.

If I double-click the buttons in design mode, dotnet wants to create new
click procedures for them with names appended with _1 (example: Private
Sub ButtonQuit_Click_1)

The question is, how do I make the button procedures match the control
names again?

The properties sheets on the controls still show them by their original
names. If it matters, I pasted the controls onto the form after adding a
tab control.

Dotnet version is 2002 SP1

Thanks

Author
19 Sep 2006 2:43 PM
Phill W.
Dave Cullen wrote:

> I did a cut & paste of some button controls on one of my forms and now
> the button procedures don't get called when the buttons are pushed.

The "Handles" clauses get /dropped/ when you cut and paste controls
around.  It's just something the IDE does.

You'll have to find each event handler in the code and add the Handles
clauses again.

Next time you feel the urge to move controls around like htis, add the
Tab Control and Tab Page to the form, save it, close the Designer and
open up the code Region that's marked "Do Not Change" .. and change it.

Look for the lines of code that add each Control to the Form:

Me.Controls.Add( Me.X )

If Me.X is one of the Controls that you want to move onto the Tab Page
(called, say, Me.Tab1), change the above line to

Me.Tab1.Controls.Add( X )

Save the Form, rebuild the project, cross your fingers and open the
Designer.  With a /bit/ of luck, your controls will have moved onto the
tab page and will still have all their event handlers attached.

HTH,
    Phill  W.
Author
19 Sep 2006 2:50 PM
Robinson
Show quote Hide quote
"Dave Cullen" <nospam@mail.com> wrote in message
news:450FFE11.7CCE1680@mail.com...
>I did a cut & paste of some button controls on one of my forms and now
> the button procedures don't get called when the buttons are pushed.
> Somehow dotnet has disassociated the buttons with their previous code.
>
> If I double-click the buttons in design mode, dotnet wants to create new
> click procedures for them with names appended with _1 (example: Private
> Sub ButtonQuit_Click_1)
>
> The question is, how do I make the button procedures match the control
> names again?
>
> The properties sheets on the controls still show them by their original
> names. If it matters, I pasted the controls onto the form after adding a
> tab control.
>
> Dotnet version is 2002 SP1
>

If you look at the "Handles" keyword after the event handler declaration,
you will see that it is no longer associated with the control.  Simply
re-insert the "Handles myControl.abc" to make it work again.

i.e.:

Private Sub DataTreeView_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles MyBase.Load

becomes.........

Private Sub DataTreeView_Load(ByVal sender As Object, ByVal e As
System.EventArgs)

so, add the "Handles MyBase.Load" in this example.
Author
20 Sep 2006 9:00 PM
Dave Cullen
You guys rock. Thanks very much.


Robinson wrote:
Show quoteHide quote
>
> "Dave Cullen" <nospam@mail.com> wrote in message
> news:450FFE11.7CCE1680@mail.com...
> >I did a cut & paste of some button controls on one of my forms and now
> > the button procedures don't get called when the buttons are pushed.
> > Somehow dotnet has disassociated the buttons with their previous code.
> >
> > If I double-click the buttons in design mode, dotnet wants to create new
> > click procedures for them with names appended with _1 (example: Private
> > Sub ButtonQuit_Click_1)
> >
> > The question is, how do I make the button procedures match the control
> > names again?
> >
> > The properties sheets on the controls still show them by their original
> > names. If it matters, I pasted the controls onto the form after adding a
> > tab control.
> >
> > Dotnet version is 2002 SP1
> >
>
> If you look at the "Handles" keyword after the event handler declaration,
> you will see that it is no longer associated with the control.  Simply
> re-insert the "Handles myControl.abc" to make it work again.
>
> i.e.:
>
> Private Sub DataTreeView_Load(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
>
> becomes.........
>
> Private Sub DataTreeView_Load(ByVal sender As Object, ByVal e As
> System.EventArgs)
>
> so, add the "Handles MyBase.Load" in this example.