Is there a way to maintain the Event handler assignments when cutting and pasting controls in the VS2012 designer? For example, I have a graph control that has a Load event with code in the Event stub. If I cut and paste the graph control, the Load event no longer shows as having an Event handler assignment in the Properties Editor. I have to use the drop-down box next to the Load event to reselect my existing Event handler code for the Load event (redo the assignment). Is there a way to cut and paste controls without losing the Event handler assignments?
In Delphi I could just cut and paste controls freely and the event handler assignments were part of the clipboard text so they were retained when a control was pasted onto a form or frame. I am hoping there is a way to do the same with Visual Studio 2012 and a C# project.
You need to use the Document Outline
View > Other Windows > Document Outline
And find your desired control and then drag and drop it to target container. In this case you wont miss any events.
When you cut or copy a control using the Visual Studio designer only the properties of the controls are copied. This is by design and in my opinion, is justified. It would be counter intuitive most of the time if you where copying a control and all of the same event handlers where assigned or copied over.
It sounds like the control is remaining in the same Form. In which case dragging and placing the control should suffice for the most part.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With