Windows.Forms Panel dynamically loads the user control UserControl

Source: Internet
Author: User

Create a good one Windows Forms program, FORM1 Add a panel control in the created program

And then add a user control to the program

Add well later again catalog see

Just create it and then pull a few buttons in the user control (to show the effect when the main function is loaded)

And then the form1_load of the main function

First in the namespace plus: using UserControlTest.Controel.tabControel;

In the new class of a user control,

private void Form1_Load (object sender, EventArgs e)
{
USERCONTROL1TC = new UserControl1 ();
THIS.PANEL1.CONTROLS.ADD (TC);
}

A dynamically loaded user control can be obtained by running the project. In this way, you can implement a drop-down list to load different controls by selecting different content.

can be flexible and convenient to use and switch!

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.