如何在Tabcontrol中设置Tabpage索引 [英] how to set Tabpage index in Tabcontrol
本文介绍了如何在Tabcontrol中设置Tabpage索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
谁能告诉我如何在tabcontrol中设置Tabpage索引.
当我将新标签添加到tabcontrol并将其移到最前面时.索引没有变化.
谢谢您,
Gani.P
Hi,
Can anybody tell me how to set the Tabpage index in tabcontrol.
When i was adding a new tab to a tabcontrol and moving it to front. the indexes are not changing.
Thanks with regards,
Gani.P
推荐答案
当您填充TabPages
属性时,索引会自动设置:
The index is set automatically when you fill theTabPages
property:
//page1 will receive index 0
tabControl1.TabPages.Add(page1);
//page2 will receive index 1
tabControl1.TabPages.Add(page2);
//page3 will receive index 2
tabControl1.TabPages.Add(page3);
如果要更改索引,只需更改添加顺序:
If you want to change indices, just change the add order:
//page2 will receive index 0
tabControl1.TabPages.Add(page2);
//page1 will receive index 1
tabControl1.TabPages.Add(page1);
//page3 will receive index 2
tabControl1.TabPages.Add(page3);
或如OriginalGriff所说,您可以使用Insert
方法.
使用BringToFront
将无济于事.
Or as OriginalGriff said, you can use the Insert
method for example.
Using BringToFront
will not help there.
使用TabPages.Insert方法代替Add:
Use the TabPages.Insert method instead of Add:
TabPage tb = new TabPage("Hello");
myTabControl.TabPages.Insert(0,tb);
这篇关于如何在Tabcontrol中设置Tabpage索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文