WinForm embedding, winform

Source: Internet
Author: User

WinForm embedding, winform

1. Add two controls on the winform

1. Container> Panel

2. Add SideBar. dll (download link: http://pan.baidu.com/s/1o6qhf9w)

(1) Place SideBar. dll under SideBar control \ bin \ Debug

(2) drag SideBar. dll to the Toolbox> regular tab.

3. The implementation result is as follows:

Note: The left side of the form is the SideBar control and the right side is the Panel container.

Ii. Background code

(1) sidebartailload event sideBar1.AddGroup ("group name"); sideBar1.Groups [0]. items. add ("member name", 1); Note: 1 is a random write, no need to use this (2) sideBar1_ItemDoubleClick event Note: Click the name of the group member, if (e. item. text = "") {// re-paint Panel panel1.Controls. clear (); Form2 f2 = new Form2 (); // hide the subform border (remove the smallest flower, maximize, close, and other buttons) f2.FormBorderStyle = FormBorderStyle. none; // indicates that the child form is not a top-level form (Note: This is very important. If the child form is a top-level form, it cannot be embedded in the parent form) f2.TopLevel = false; // load the subform into panel this. panel1.Controls. add (f2); f2.Show ();}View Code

 

 

 

III,

4. End with source code: http://pan.baidu.com/s/1i3sZhbR


How to embed form forms (panel and subforms) in WinForm)

Today, I encountered a problem when working on the project. The form is divided into two parts: left and right. When you click the button on the left sidebar, the form is dynamically loaded on the right.
Finally, I tried to use panel to implement it. After several failures and searching for information, I finally got it done.
Note: If you need to add panel. clear () to perform multiple switchover, clear the original panel content.
Environment: C # VS2008
Method 1: attach sub-elements to the panel.
Form2 form =
New Form2 ();
Form. FormBorderStyle = FormBorderStyle. None; // hide the border of the subform (remove the smallest flower, maximize, close, and other buttons)
Form. TopLevel =
False; // indicates that the subform is not a top-level form.
This. panel1.Controls. Add (form); // load the subform into the panel.
Form. Show ();
Method 2: Specify the parent container implementation
Form2 form = new Form2 ();
Form. MdiParent = this; // specify the current form as the top-level Mdi form
Form. Parent = this. Panel1; // indicates that the Parent container of the child form is
Frm. FormBorderStyle = FormBorderStyle. None; // hide the subform border. Of course, this can also be implemented in the subform form loading event.

. NET. How can I embed a webpage in a winform?

Find the webbrowser control in the toolbox, drag it to the desired location, and set its url attribute.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.