简体   繁体   English

如何使C#选项卡在窗体之间切换

[英]How to make C# tab switch between form

I want to know if it possible to use tabs (like Google Chrome or many others program) in VS Express 2010 to swap between forms without closing any window. 我想知道是否可以在VS Express 2010中使用选项卡(例如Google Chrome或许多其他程序)在表单之间交换而不关闭任何窗口。

I know there is the tab control item in the tool box but as far as I know you need to create the tab content in the same form. 我知道工具框中有选项卡控件项,但据我所知您需要以相同的形式创建选项卡内容。 I'm looking for a way to swap between form like if I put Buttons in the the top of each form (workers, customers, ext) that open the form I clicked and close the one I'm in but not change the main window. 我正在寻找一种在表单之间进行交换的方法,例如是否将Buttons放在每个表单(工作人员,客户,分机)的顶部,这些按钮会打开我单击的表单并关闭我所在的表单,但不更改主窗口。

You can use MDI parent method. 您可以使用MDI父方法。 If I understand rightly, this link will help you. 如果我理解正确,则此链接将为您提供帮助。

OR 要么

You want it to be in the same window. 您希望它在同一窗口中。

  1. Add this code this.IsMdiContainer = true; 添加此代码this.IsMdiContainer = true; to main form. 到主要形式。

  2. Create new form for every menu or button click. 为每个菜单或按钮单击创建新表单。

     Form1 frm1; Form2 frm2; Form3 frm3; 
  3. Create this function and call every button click for make to hide all form 创建此函数并调用每个按钮以使make隐藏所有表单

     private void HideForms() { int frmCount = this.MdiChildren.Count<Form>(); if (frmCount > 0) { for (int i = 0; i < frmCount; i++) { this.MdiChildren[i].Hide(); } } } 
  4. After that button1, button2,... click event 在那个button1,button2,... click事件之后

     private void button1_clicked(...) { HideForms(); if ((frm1 == null) || (frm1.IsDisposed)) frm1 = new Form1(); frm1.MdiParent = this; frm1.Dock = DockStyle.Fill; frm1.Show(); frm1.BringToFront(); } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM