[英]How do I uniquely identify tab control?
I was planning to do something like this when certain condition is satisfied and the below code will run many times. 我计划在满足某些条件并且下面的代码将运行多次时执行类似的操作。
TabPage newtabcontrol = new TabPage();
tabControl1.Controls.Add(newtabcontrol);
But how do I know the tabIndex for the latest tabpage I just added? 但是我怎么知道我刚刚添加的最新标签页的tabIndex?
You can assign TabPage
a unique name 您可以为
TabPage
分配一个唯一的名称
As for example 例如
TabPage newtabcontrol = new TabPage();
newtabcontrol.Name = "ID-1";
tabControl1.Controls.Add(newtabcontrol);
And to find the tabPage
, you can use 并找到
tabPage
,您可以使用
var tabPage = tabControl1.TabPages["ID-1"]
if (tabPage != null)
{
// perform action
}
For last tabPage which added: 对于最后添加的tabPage:
TabPage newtabcontrol = new TabPage();
tabControl1.Controls.Add(newtabcontrol);
TabPage temp = tabControl1.TabPages[tabControl1.TabCount - 1];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.