SuperTabEx

public static void AddTabControl(string MainTabControlName, SuperTabControl objTabControl, Form objfrm)
        {
            try
            {
                SuperTabItem tab = TraverseForm(MainTabControlName, objTabControl);
                if (tab == null)
                {
                    tab = objTabControl.CreateTab(MainTabControlName);

                    objfrm.FormBorderStyle = FormBorderStyle.None;
                    objfrm.TopLevel = false;
                    objfrm.Visible = true;
                    tab.AttachedControl.Controls.Add(objfrm);

                    //设置当前选项卡为新增选项卡
                    objTabControl.SelectedTab = tab;
                }
                else
                {
                    //设为当前选中的选项
                    objTabControl.SelectedTab = tab;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }


        /// 
      /// 选项卡的键值
      /// 要添加到的TabControl对象
      /// 
        public static SuperTabItem TraverseForm(string MainTabControlName, SuperTabControl objTabControl)
      {
          //遍历选项卡判断是否存在该子窗体
          foreach (SuperTabItem con in objTabControl.Tabs)
          {
              SuperTabItem tab = (SuperTabItem)con;
              if (tab.Text == MainTabControlName)
              {
                  return tab;//存在
              }
          }
          return null;//不存在
      }


你可能感兴趣的:(C#,exception,string,null)