本文介绍了的WinForms TabControl的 - 添加新标签页按钮(+)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如何添加一个 +
按钮在的TabControl
在Windows窗体应用程序。这里是的答案。但我想它在WinForms应用程序?
How can I add a +
button to the TabControl
in a Windows Forms Application. Here is an answer for WPF. But I want it in WinForms application?
推荐答案
我想补充一个新的TabPage,然后将头+,设置它的名字新标签页,为的TabControl的SelectedIndexChanged添加事件。然后你只需检查
I would add a new TabPage, then set the header to "+", set it's name to newTabPage and add an event for the TabControl's SelectedIndexChanged. Then you just check if
tabcontrol.SelectedTab == newTabPage
,如果是这样的话,你可以创建一个新的TabPage,将它插入的TabControl并将其设置为像SelectedTab:
and if that is the case you can create a new TabPage, insert it into tabControl and set it as the SelectedTab like:
tabControl.TabPages.Insert(tabControl.TabPages.Count - 1, createdTabPage);
tabControl.SelectedTab = createdTabPage;
这篇关于的WinForms TabControl的 - 添加新标签页按钮(+)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!