简体   繁体   中英

How to Embed a Form within another Form in c#?

In an internet webpage , there is a constant menu usually placed on the top or left of a page from which user can navigate (They call it Iframes) ..

I would like to know if it is possible to do something like that using WinForm applications or WPF applications in c# .

At present I am simply inheriting forms from a base class . and each time the user needs to navigate , I have no option but to open up a new form with the same Peristent menu ...

Any suggestions here ?

You mean like an MDI application (http://www.codeproject.com/KB/cs/myBestMDI.aspx) or just using a SplitContainer on the form? Really there are many options. WPF has ElementHost I think. Did you do any research yet? What did you find?

You could also take the toolbox approach. Have a parent program start the menu form and then other forms can use it... or it can launch from it... what ever your use case is.

You could use an MDI-container in WinForms. see here and here for more information.

I managed to use usercontrol to embed a form into another ..

Form1 has a userControl , Form2 embedded inside the user control .

things to note was .. the embedded forms toplevel property should be set to false the embedded forms FormBorderStyle should be set to none

userControl1.Controls.Clear();
Form2 f = new Form2();
f.Toplevel=flase;
f.Show();
f.TopLevel = false;
userControl1.Controls.Add(f);

Well, there should be a frame component in WPF which will give you such an option. Then you would use a "view" concept to open the WPF Pages you direct the user to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM