Button problem

  • Thread starter Thread starter Gary Paris
  • Start date Start date
G

Gary Paris

On my windowsform, I have a tab control. On the control, I have as button
called btnSave. I wanted to move the button off the tab control and onto
the windowsform. Shouldn't be a problem I thought. When I highlighted the
button, I did a CTRL-X then a CTRL-V to paste the button on the form.

Now the click event doesn't work. The button still has the same name, but
when I double click on the button, the method that is created is called
btnSave_Click_1. It seems that the button has been renamed, but when I
look at the properties, the name still says btnSave.

Anybody know what is going on?

Thanks,

Gary
 
There is as designed. What's happening is that you still have the old event
handler, but when you cut and pasted the control, VS disassociated it with
the button. (i.e. it no longer says Handles btnSave.Click after it.)

When you double click, VS is adding the _1 because there is already a sub
called btnSave_Click and it wants to create an event handler. Since the
name of the handler doesn't really matter, it just tacks on the _1 and
specifies that it Handles btnSave.Click.

To "fix" this, just add the "Handles" code back to the original sub routine
and delete the _1 stuff.

Jerry
 

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

Back
Top