skip1000
asked on
Object name on properties and code is different
Hi,
I'm new to c# and I noticed that when the name of an object is changed in the properties, the code does not get updated automaticaly. Even when I double-click on the object to create new code, the old object name is used in the code. Why does it not update automatically. It is difficult to build and run the code as a result. This sounds like something trivial that I can't figure out. Any explanations or answers? Thanks.
I'm new to c# and I noticed that when the name of an object is changed in the properties, the code does not get updated automaticaly. Even when I double-click on the object to create new code, the old object name is used in the code. Why does it not update automatically. It is difficult to build and run the code as a result. This sounds like something trivial that I can't figure out. Any explanations or answers? Thanks.
ASKER
Hi martin,
The trouble is that even when after I rename the object in the properties, creating a new event for the property will still show the old name. Is it because the self-generated declaration codes does not update w/ the name change in the properties? Thanks.
The trouble is that even when after I rename the object in the properties, creating a new event for the property will still show the old name. Is it because the self-generated declaration codes does not update w/ the name change in the properties? Thanks.
Example, put a button on a form with the name button1 and create a click event that is named button1_Click.
Then rename the button to button2. The click event will still be named button1_Click, so you have to go to the events tab in properties and rename that to button2_Click.
If you then add an event for MouseClick, it should be named button2_MouseClick.
Does this not happen for you? Which version of Visual Studio are you using?
Then rename the button to button2. The click event will still be named button1_Click, so you have to go to the events tab in properties and rename that to button2_Click.
If you then add an event for MouseClick, it should be named button2_MouseClick.
Does this not happen for you? Which version of Visual Studio are you using?
ASKER
Hi Martin,
I'm using vs.net 2003. I've seen cases where button2 (after renamed) where it would appear as button1_click and other cases as button2_click. That behavior is strange and is the reason why I'm confused. I did not apply any service packs.
I'm using vs.net 2003. I've seen cases where button2 (after renamed) where it would appear as button1_click and other cases as button2_click. That behavior is strange and is the reason why I'm confused. I did not apply any service packs.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok. Then I guess there will be no easy way to resolve this except to fix the codes if the codes don't compile. Thx.
If for example you create a button named button1, and then create an event by double-clicking on it, the event will be named button1_Click.
If you later change the name to buttonOK you have to go to the properties pane and click on the button that looks like a flash to see the events, there you can rename the event as well.