Can I upload a new panel to the panel?

I am working on a Windows Application. I have menustrip in one form, and I want to ask if I can have a panel that will load a new form with a certain click on menustripitem.

Example:

File Data ABC Hello XYZ Bye 

This is my menu bar. By clicking on ABC, I do not want to go to another form, can I do something (no matter what I want) in the same form using the panel.

thanks

+4
source share
5 answers

I think I had the same question.

But I found an answer for him

Sample Project Code

First you need to configure the form:

 myForm.FormBorderStyle = FormBorderStyle.None; 

And then, it manipulates the action:

 Form1 myForm = new Form1(); myForm.TopLevel = false; myForm.AutoScroll = true; frmMain.Panel2.Controls.Add(myForm); myForm.Show(); 

Hope to help you. Hugs: D

+4
source

You can use MDI . Try something like this

  //Create a new instance of the MDI child template form Form2 child= new Form2(); //Set parent form for the child window child.MdiParent=this; //Display the child window child.Show() 

You can also refer to this site .

+1
source

If you put all the contents of the target form in the UserControl, you can add a panel to your main form and place the UserControl panel on it.

You have the ability to display a separate form by creating an empty form and placing the same UserControl in this form.

As Int3 already points out, you can use MDI forms. However, if you want to use dockable panels, UserControl is the way to go.

0
source

Add two panels to your form, only one will be displayed at a time. Then add two events to your menus:

 private void ABCToolStripMenuItem_Click(object sender, EventArgs e) { panelABC.Visible = true; panelXYZ.Visible = false; } private void XYZToolStripMenuItem_Click(object sender, EventArgs e) { panelABC.Visible = false; panelXYZ.Visible = true; } 
0
source
  private void pbxpurchase_Click(object sender, EventArgs e) { contentpnl.Controls.Clear();//contentpnl is the panelname purchasebook purchasebk = new purchasebook();//purchasebook is a formname purchasebk.TopLevel = false; purchasebk.AutoScroll = true; contentpnl.Controls.Add(purchasebk); purchasebk.Dock = DockStyle.Fill; purchasebk.Show(); } 

try this 100% tested

0
source

Source: https://habr.com/ru/post/1379452/


All Articles