繁体   English   中英

如何唯一标识选项卡控件?

[英]How do I uniquely identify tab control?

我计划在满足某些条件并且下面的代码将运行多次时执行类似的操作。

TabPage newtabcontrol = new TabPage();
tabControl1.Controls.Add(newtabcontrol);

但是我怎么知道我刚刚添加的最新标签页的tabIndex?

您可以为TabPage分配一个唯一的名称

例如

TabPage newtabcontrol = new TabPage();
newtabcontrol.Name = "ID-1";
tabControl1.Controls.Add(newtabcontrol);

并找到tabPage ,您可以使用

var tabPage = tabControl1.TabPages["ID-1"]
if (tabPage != null)
{
    // perform action
}

对于最后添加的tabPage:

TabPage newtabcontrol = new TabPage();
tabControl1.Controls.Add(newtabcontrol);

TabPage temp = tabControl1.TabPages[tabControl1.TabCount - 1];

暂无
暂无

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

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