I want to load a desktop application, via reflection, as a Control inside another application.
The application I'm reflecting is a legacy one - I can't make changes to it.
I can dynamically access the Form, but can't load it as a Control.
In .Net Form expands on Control, and I can assign the reflected Form as a Control, but it throws a run-time exception.
Forms cannot be loaded as controls.
Is there any way to convert the form to a control?
Add the control by drawingSelect the control by clicking on it. In your form, drag-select a region. The control will be placed to fit the size of the region you selected.
Forms namespace contains a large family of controls that add both form and function to a Windows-based user interface. Each control inherits a common set of members from the Control class. To these, it adds the methods, properties, and events that give the control its own distinctive behavior and appearance.
What is Control in c# programming Language? C# Control Windows Forms controls are reusable components that encapsulate user interface functionality and are used in client-side Windows applications. A button is a control, which is an interactive component that enables users to communicate with an application.
Yes, this works just fine. I'm working on a .NET app right now that loads forms into a panel on a host form.
The relevant snippet:
// setup the new form
form.TopLevel = false;
form.FormBorderStyle = FormBorderStyle.None;
form.Dock = DockStyle.Fill;
form.Show ( );
// add to the panel's list of child controls
panelFormHost.Controls.Add ( form );
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