我有一个创建一系列tabPages的方法,尽管它只定义了" text"它们的价值(标题),如何设置"名称"标签页面也是?
foreach (string s in hostnames)
{
TreeNode newNode = new TreeNode(s);
hostView.SelectedNode.Nodes.Add(newNode);
string title = s;
TabPage myTabPage = new TabPage(title);
tabControl1.TabPages.Add(myTabPage);
}
答案 0 :(得分:2)
您可以使用Name属性设置名称:
foreach (string s in hostnames)
{
TreeNode newNode = new TreeNode(s);
hostView.SelectedNode.Nodes.Add(newNode);
TabPage myTabPage = new TabPage(s);
myTabPage.Name = "Name you want to set";
tabControl1.TabPages.Add(myTabPage);
}