buttons stopped working

D

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
 
P

Phill W.

Dave said:
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.
 
R

Robinson

Dave Cullen said:
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.
 
D

Dave Cullen

You guys rock. Thanks very much.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top