简体   繁体   English

修复选项卡中的Tabcontrol选项卡位置

[英]Fix Tabcontrol Tabpage location in tabs

I have a TabControl in Winforms that I can Remove a tabpage with a button via the code : 我在Winforms中有一个TabControl,可以通过代码删除带有按钮的标签页:

            TabControl1.Tabpages.Remove(TabPage1)

however, when I add the tabpage again using this code 但是,当我再次使用此代码添加标签页时

            TabControl1.Tabpages.Add(TabPage1)

the tabpage gets added in after the last tabpage. 该选项卡页面被添加到最后一个选项卡页面之后。

How do I restore the ORIGINAl location of the tabpage in the tabControl? 如何在tabControl中还原选项卡页的原始位置?

First, you'll have to store the original index so that you know where to put it back to: 首先,您必须存储原始索引,以便知道将索引放回何处:

index = TabControl1.TabPages.IndexOf(TabPage2)
...
...    
TabControl1.TabPages.Insert(index , TabPage2)

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

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