Пример #1
0
 private void tsMenuItemCloseAll_Click(object sender, EventArgs e)
 {
     for (int i = tabControlMain.Tabs.Count - 1; i >= 0; i--)
     {
         // 主窗口不关闭
         if (i == 0)
         {
             return;
         }
         TabItem ti = tabControlMain.Tabs[i];
         tabControlMain.Tabs.Remove(ti);
         ti.Dispose();
     }
     tabControlMain.Refresh();
 }
Пример #2
0
 private void tsMenuItemCloseOther_Click(object sender, EventArgs e)
 {
     int i = 1;
     while (tabControlMain.Tabs.Count > 1)
     {
         if (tabControlMain.SelectedTabIndex == 1)
         {
             i = 2;
         }
         if (i == 2 && tabControlMain.Tabs.Count == 2)
         {
             break;
         }
         TabItem ti = tabControlMain.Tabs[i];
         tabControlMain.Tabs.Remove(ti);
         ti.Dispose();
     }
     tabControlMain.Refresh();
 }