My question is easy, I copy a control (a button) on my project.cs[Design] into my clipboard. How can I use it outside this project.cs[Design] ?
-
4Your last 2 sentences have made me lose my mind. – Pubby Nov 13 '11 at 07:44
-
I need more information, what have you tried? Have you tried just pasting it? It should work just like copying and pasting anything else in most cases. – Beth Lang Nov 13 '11 at 07:47
-
if u mean that u need to paste it in your own GUI , you need first to explore what's copied in the clipboard and it's structure . second you must develop your own handler to convert this class to the GUI – Hady Elsahar Nov 13 '11 at 08:34
5 Answers
On the clipboard, it is only known as a byte array. In my own case, I created an application to set translated captions to some controls. It would be great if I could copy the controls in Visual Studio, then "paste" them into my application so the names and default texts can be read. Alas, if all I get is a byte array, it just does not work.

- 11
- 1
I think you may be confusing the "button" with the logic behind it.
If you want to add a button using visual studio, then you need to open the "toolbox" task window and grab it from the windows controls.
But I think what you are trying to do is copy the logic. You can do this by double clicking on the button in the design view. This shall take you to the section of the code which is wired to the buttons OnClick event. You can then copy the logic there for adaption into another project.

- 28,526
- 15
- 68
- 103
You cannot use it outside the control designer. It is not just a graphics object that can be pasted anywhere.

- 25,272
- 21
- 67
- 103
the good news is that it's not an internal visual studio handler it's copying something to the system's clipboard . ( u can try copying a controller and paste it to another Visual studio design page and it will work )
you should print out what is in the clipboard using code . and observe a little bit about how it's copied
if you are managing to write your own code to handle this i maybe you can observe the copied class using reflection and make your own GUI to show it with it's properties ( just a Guess )

- 2,121
- 4
- 29
- 47
just paste it on any form you want,yet problem then copy code created by Visual studio from designer.cs file of taht form and paste to another form's designer.cs file.

- 175
- 2
- 15