C #, how to switch the window by clicking on the button

Method is as follows:

1. Design of a first place on the left panel, a right panel place (named pnlMain), resize, placing two buttons (a plurality of buttons Similarly) in the left panel

2. In the button inside the write method

   Write the following method in naming [check] button (I wrote the code testing tools) in

   private void btnNameCheck_Click(object sender, EventArgs e)

        {

            this.pnlMain.Controls.Clear (); // initialize the master panel

            NameRule nr = new NameRule (); // instantiate pnlMain to be displayed in the form (NameRule is a new form)

            nr.TopLevel = false; // set properties

            nr.Show (); // display form

            this.pnlMain.Controls.Add (nr); // add from there to pnlMain

        }

    Click achieved [check] button to display the naming of a new form in the panel

     Similarly written in the same manner as another button which, opens another form

    private void btnCodeLineCheck_Click(object sender, EventArgs e)

        {

            this.pnlMain.Controls.Clear();

            CodeLineCount clc = new CodeLineCount();

            clc.TopLevel = false;

            clc.Show();

            this.pnlMain.Controls.Add(clc);    

        }

 

 

Guess you like

Origin www.cnblogs.com/blogpro/p/11459930.html
Recommended