Captain Banana

Hello,
I'm just starting out with Visual Studio having spent many years using the Delphi IDE.

I'm used to a feature where you can cut controls from a form, and when you paste the controls back on the form, it will reattach all the event handlers automatically. However, in Visual Studio is appears to lose the link between the control and the event handler, requiring me to manually reattach them all.

I find this feature useful while making design changes to a form, such as cutting a bunch of controls and pasting them back into a new panel (for example). Although I can do something similar by dragging controls around the form, it doesn't seem quite as neat a solution as to what I am used to.

If this feature has never existed in Visual Studio, I guess people are used to the way the cut/paste works, but I really miss it (even if it was an option that could be enabled)..

Another thing I've noticed is that when you rename a control, it doesn't seem to automatically rename the default event handler names to reflect the updated name. Perhaps there are some options I haven't found

Thanks for any info,
David



Re: Visual C# IDE Cut and Paste of Controls - Loses Event Handler Links

CommonGenius.com

I'm not sure why you would cut controls from a form and then paste them back onto the same form. To me, dragging seems a lot easier, but I guess that's a preference issue. But regardless of preference, when cutting and pasting you are removing the controls from the form, and then placing them again. The IDE never adds event handlers to newly placed controls, even if they are copied from controls that had event handlers. For all it knows, you don't want them to have event handlers at all, or maybe you want them to have different handlers. It lets you decide, rather than automatically attaching event handlers that you may not want, which could lead to hard-to-find bugs. If the IDE did automatically attach handlers to pasted controls, I would call it a bug, not a feature It would be nice if it were an option though. You might consider filing a suggestion at http://connect.microsoft.com/VisualStudio/feedback. In the meantime, if all you are doing is changing the location of a control, I would highly recommend that you simply drag it to where you want it to be.

And no, event handler names are not updated when you change the name of a control. I think there might have been some concern about accidentally changing names that shouldn't be changed. References can be automatically updated because the IDE actually compiles the application and then uses the debug symbols to find any references. Names are more difficult because the IDE can't know ahead of time what naming conventions you are using. Seems like they might have been able to implement some very restrictive name changes in obvious cases though. Maybe another candidate for suggestion.