Click to See Complete Forum and Search --> : [RESOLVED] VS 2005 Neatness?
Pale
July 17th, 2008, 05:28 PM
If you write an application without renaming the buttons and textboxes. And you would like to rename them when you are finished with it. VS doesn't rename the (button1_click).
Eg. If you pull off a button leave the name default, and add some action to that button. But you later decide to rename it, it does rename it but it doesn't rename button1_click in form1.cs. And if i try to change it manually i get an error when compiling.
Is there a way to get that renamed?
Thanks
eclipsed4utoo
July 17th, 2008, 05:36 PM
name it correctly to begin with. That should be the first thing you do when you add a control to a form.
for the button click event, go to the events list, right click on the event and choose "Reset", then double click on the event again and it will create a new click event with the correct name. then copy the code from one event to the other, then delete the old event handler.
Pale
July 17th, 2008, 05:48 PM
thank you
cjard
July 17th, 2008, 06:48 PM
jeez, what a horrible way round of doing things.
Just incase you never noticed, go and rename your button1_click to something nicer, but dont move the cursor away from the edited word. See the little widget appear at the end of what you edited? Point to that and you'll get an option to rename all occurrences..
Or, if this technique doesnt get on with you, simply right click on the words "button1_click" and choose Refactor >> Rename
All matching occurrences will be renamed, and this should be beyond a normal find.replace.. it only renames things that refer to that actual method. If you had "button1_click" inside a string, then it would NOT find/replace that.. (unless you tick the box to look for it)
Look:
cjard
July 17th, 2008, 06:57 PM
name it correctly to begin with. That should be the first thing you do when you add a control to a form.
for the button click event, go to the events list, right click on the event and choose "Reset", then double click on the event again and it will create a new click event with the correct name. then copy the code from one event to the other, then delete the old event handler.
ps it rarely makes methods with the correct name.. if you rename your button to be "goButton" or maybe better _goButton, the generated method is "goButton_Click" and it should be "GoButton_Click"
instance.Method()
instance.Property
instance.field
boudino
July 18th, 2008, 02:20 AM
Or you can just go to the InitilizeComponent() method (it is located in *.Designer.cs) and there look for this.button1.Click += new System.EventHandler(this.button1_Click); and simply edit it.
boudino
July 18th, 2008, 02:22 AM
... and what a fun if corporate policy says that private methods and properties begins with small letter.
Than what could mean code like: clientId = this.defaultClientId. What clientId and defaultClientId are? Fields? Properties?
cjard
July 18th, 2008, 03:23 AM
Or you can just go to the InitilizeComponent() method (it is located in *.Designer.cs) and there look for this.button1.Click += new System.EventHandler(this.button1_Click); and simply edit it.
Considering how good C# is at refactoring, that seems like the long way headache to me..
cjard
July 18th, 2008, 03:25 AM
... and what a fun if corporate policy says that private methods and properties begins with small letter.
Than what could mean code like: clientId = this.defaultClientId. What clientId and defaultClientId are? Fields? Properties?
and especially in VB.NET where you dont have to include () brackets in a method call if there are no args. but then the precision of c#'s case sensitivity is usually lost on those guys
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.