Reputation: 1233
Let's say there's a Windows Forms App and there's a button called button1
.
I double click on a button, it creates an event handler called private void button1_Click(object sender, EventArgs e)
. Then I rename this button from button1
to myButton
.
I would like to make IDE to rename all event handlers for this button from button1_
to myButton_
accordingly and also rename all references it can find in a solution to these event handlers.
I understand it can probably introduce problems in some specific cases, but that's what I currently do manually: rename event handler in the designer, it creates new handler in the code, then delete empty handler and rename original handler. And repeat for every handler for this control.
I would like to automate it with a single shortcut "Rename all event handlers and references to these event handlers for this control".
I hope it makes sense what I want to achiever here. Is there a way to do this?
Upvotes: 1
Views: 671
Reputation: 3994
All you have to do is rename the event handler in the code.
button1_Click(object sender, EventArgs e)
button1
and change it to myButton
.This will update the reference on the form and all other places in the code which reference the event handler.
Upvotes: 2