private void button2_Click(object sender, EventArgs e)
{
bool have = false;
foreach (TabPage a in tabControl1.TabPages)
{
if (a.Name == "KKK") //tabpage名 kkk
{
have = true;
}
}
if (!have)
{
TabPage TabPageCity1 = new TabPage("KKK");
TabPageCity1.Name = "KKK";
this.tabControl1.TabPages.Add(TabPageCity1);
FormCity frmCity = new FormCity(); //FormCity:From
frmCity.TopLevel = false;
frmCity.Parent = TabPageCity1;
frmCity.ControlBox = false;
frmCity.Dock = System.Windows.Forms.DockStyle.Fill;
frmCity.Show();
this.tabControl1.SelectedTab = TabPageCity1;
}
else
{
MessageBox.Show("cz");
}
}
转载于:https://www.cnblogs.com/fengdiechang/archive/2009/09/08/1562708.html