Re: button click event question

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Chris R. Timmons (crtimmons_at_X_NOSPAM_Xcrtimmonsinc.com)
Date: 07/05/04


Date: Sun, 04 Jul 2004 21:38:01 -0700

Tony <none@none.com> wrote in
news:ptkhe0t22t1gctic46qv347snnleek1the@4ax.com:

> I put three buttone on my form.
> Double clicked the first button and got the below code
>
> private void button1_Click(object sender, System.EventArgs e)
> {
> }
>
> I put some stuff in it and then it occured to me that I left the
> button's name etc default..
>
> Went to the putton's properties and changed the name of the
> button to "btnAdd"
>
> Double clicked the button again expecting it to create
>
> private void btnAdd_Click(object sender, System.EventArgs e)
> {
> }
>
> But intead, it put me back into the same Button1 click event
> code..
>
> I figured VS must be confused and changed the event to
> private void btnAdd_Click(object sender, System.EventArgs e)
> {
> //some stuff here
> }
>
> And tried a debug compile... It complained that there wasn't a
> click event for button1
>
> I'm sure I've done this in VB6 with no problems..
>
> What am I not seeing here?

Tony,

VS.Net isn't smart enough to do that automatically. The code that's
causing the problem is in the code that was generated by VS.Net. You
can safely do a manual replacement by searching your source code for
button1_Click and replacing it with btnAdd_Click.

-- 
Hope this helps.
Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/

Quantcast