c# tabcontrol组件如何显示FORM
如题,即当点击menuStrip1组件或toolStrip1组件中的某一项时,不再跳出FORM而全部显示到tabcontrol中,显示的Tabpage页标题名称也是取该组件中某项的名称,FORM窗体是先设计好的,需把内容全变成标签窗体;每新增一窗体时即显示新增的窗体,如关闭该窗体时就显示上一次打开的窗体。
C# code 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"); } }
设置FormBorderStyle为None就没有标题栏了
以上是C# Tabcontrol组件如何切换显示Form窗体的示例代码的详细内容。更多信息请关注PHP中文网其他相关文章!