I have a C++/CLI project which has a child form with some control components. I would like to copy all the control components with their codes on a new Tab control on the main form. How can I do that?
相关问题
- How to know full paths to DLL's from .csproj f
- Importing NuGet references through a local project
- Visual Studio 2019 - error MSB8020: The build tool
- 'System.Threading.ThreadAbortException' in
- Visual Studio 2010 randomly says the command line
相关文章
- How to show location of errors, references to memb
- Log4Net Multiple Projects
- How to track MongoDB requests from a console appli
- Compiling error in C++ project with C and C++ code
- Visual Studio Hangs on Loading UI Library
- How to use Mercurial from Visual Studio 2010?
- VSIX: execute code on VS startup
- Copy different file to output directory for releas
You can select all of the controls in the designer (hold down the Shift key to make multiple selections), and then cut and paste them to their new location: Ctrl+X, Ctrl+V
Alternatively, you can open up the
*.Designer
file that is generated automatically by the Windows Forms designer and copy the relevant lines of code out of that file into your other code file. Look for the code that creates and sets properties on the controls you're interested in. For every property of the control that you have set to its non-default value in the designer, there will be a line for it in this file.If, instead of moving (cutting) the controls from one place to another, you want to copy the controls so that they appear in multiple places, I strongly suggest creating a
UserControl
that contains all of the child controls and encapsulates the relevant code. Then, you can just drop an instance of this customUserControl
out of your toolbox into whatever form you want, or even dynamically create instances at runtime. This is consistent with the general programming/design principle that you should seek to keep code duplication to a minimum while encapsulating as much as possible.