Button_Click change

K

Kenneth

Hi,

I'm using VS.NET 2002 with code behind.

If I add a button to the design and don't change the id,
i.e. 'Button1' but activates and write some code to the
click event and then later change the 'Button1' id
to 'btnSave' or something in designview, then I've tried
to change the Sub Button1_Click to btnSave_Click, but this
doesn't seem to work.

What and in which sequence should I do to have the new
btnSave_click event get up and work?

TIA

/Kenneth
 
L

LIN

simple jus delete the code u have written for button1 's click event an then
go to design view and double click on the btnSave_Click button for the .vb
page to open where your cursor is in the on click event sub of tht button
...so can write ur click event code here
 
Y

Yusuf D M

Change the ID of the button in nitializeComponent() function also to fire
the event.
 
D

Daniel Bass

A method is associated with the events (like clicks, updates etc) in two
ways...

the first is as mentioned by Yusuf,... the initialise component you'll see
the button and the event, and the method linked to this event, change this.
the second is that the method has the Handles operator on the back of it,
something like:

Private Sub button1_Click (ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles buttonOK.Click

It's either one or the other, I don't think it's both.

Hope that helps.
Dan.
 
K

Kevin Spencer

In VS.Net, it is not necessary to make any change to the name of the Event
Handler, as the IDE will adjust the name of the control where it is
necessary. The name of the event handler is of no consequence, as long as it
references the correct name of the control for which it is designed.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
The more I learn, the less I know.
 

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

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top