且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

按钮上的选项卡控件中打开Windows窗体单击

更新时间:2023-12-06 12:19:52

在按钮单击事件中,您执行以下操作:

In the button click event, you do:
Form2 frm = new Form2();  //Or whatever your form is called
frm.Show(this);



或(如果你想以模态方式打开它):


or (if you want to open it modally):

Form2 frm = new Form2();  //Or whatever your form is called
frm.ShowDialog(this);


您还需要在tabpages的控件集合中添加表单对象,如下所示:



You also need to add form object in tabpages'' control collection as below:

private void button1_Click(object sender, EventArgs e)
{
    Form2 frm = new Form2();
    frm.TopLevel = false;
    tabPage1.Controls.Add(frm);
    frm.Dock = DockStyle.Fill;
    frm.Show();
}


检查这个

选项卡式MDI子窗体 [ ^ ]