TabPage判断重复添加Page

.....

........

...........代码如下:

 1  bool isPag = true;
 2                 foreach (TabPage page in tbpDynamicMenu.TabPages)
 3                 {
 4                     if (nodeName.Equals(page.Text))
 5                     {
 6                         tbpDynamicMenu.SelectedTab = page;
 7                         isPag = false;
 8                         break;
 9                     }
10                 }
11                 if (isPag)
12                 {
13                     //添加选卡
14                     TabPage tbp = new TabPage();
15                     tbp.Text = nodeName;
16                     tbpDynamicMenu.Controls.Add(tbp);
17                     tbpDynamicMenu.SelectedTab = tbp;
18                 }

 

你可能感兴趣的:(TabPage判断重复添加Page)