Windows Forms: How to Add the Form in Panel from another Form in C#
By FoxLearn 9/24/2019 11:50:04 PM 33.06K
How to open a Form in a Panel using C#
The panel is a Windows Forms control that lets you add other controls to it.
In addition to adding UserControl or Control to the Panel, sometimes you will need to create an application that allows you to open multiple Forms in a Panel from one Form. You can easily add Form in Panel C# in the following way.
Creating a new Windows Forms Application project, then open your form designer. Next, You can drag Button, Label, Combobox and Panel controls from your Visual Studio Toolbox to your winform.
Next, Create a new Form with the name Form2, then you can design a simple UI as shown below.
Clicking the Combobox control in Form1, then select Edit Items...
Next, You need to add the above items into the combobox.
You can also create Form3, Form4...etc, then open your form similarly in the following way.
How to load a form inside another form in c#
Adding a click event handler to the ShowForm button allows you to open a new Form inside a Panel in C# as shown below.
private void btnShowForm_Click(object sender, EventArgs e) { Form2 frm = new Form2() { TopLevel = false, TopMost = true }; frm.FormBorderStyle = (FormBorderStyle)cboFormStyle.SelectedIndex; this.pContainer.Controls.Add(frm); frm.Show(); }
If you want to open new form in same window or load form inside panel other form in c# , i think this is the best solution.
VIDEO TUTORIAL
- Windows Forms: Text to speech in C#
- Windows Forms: Print Picture Box in C#
- Windows Forms: Advanced Filter DataGridView in C#
- Windows Forms: Progress Bar in C#
- How to create a Lucky Draw games in C#
- Windows Forms: Youtube Search with Paging in C#
- Windows Forms: How to Create a Random Password Generator in C#
- Windows Forms: Tag Control in C#