码迷,mamicode.com
首页 > Web开发 > 详细

DotNetBar-tabcontrol

时间:2017-09-02 10:34:50      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:color   logs   string   text   add   blog   turn   ==   level   

super

        /// <summary>
        /// 添加Tab页
        /// </summary>
        /// <param name="frm"></param>
        private void AddForm(Form frm)
        {

            this.superTabControl1.Visible = true;
            if (!IsOpenTab(frm.Text))
            {
                SuperTabItem tabItem = superTabControl1.CreateTab(frm.Text);
                SuperTabControlPanel tcp = new SuperTabControlPanel();
                tabItem.AttachedControl = tcp;
                tcp.TabItem = tabItem;
                tcp.Dock = DockStyle.Fill;
                tcp.Name = frm.Name + "Tab";
                frm.TopLevel = false;
                frm.Dock = DockStyle.Fill;
                frm.FormBorderStyle = FormBorderStyle.None;
                frm.Show();
                tcp.Controls.Add(frm);

                superTabControl1.Controls.Add(tcp);
                superTabControl1.SelectedTab = tabItem;
            }
        }

        /// <summary>
        ///  检查是否已打开某个子窗体
        /// </summary>
        /// <param name="tabName"></param>
        /// <returns></returns>
        private bool IsOpenTab(string tabName)
        {
            bool isOpened = false;

            foreach (SuperTabItem tab in superTabControl1.Tabs)
            {
                if (tab.Text.Trim() == tabName.Trim())
                {
                    isOpened = true;
                    superTabControl1.SelectedTab = tab;
                    break;
                }
            }
            return isOpened;
        }

TabControl

    /// <summary>
        /// 添加Tab页
        /// </summary>
        /// <param name="frm"></param>
        private void AddForm(LisBaseForm frm)
        {
            this.tabControl1.Visible = true;
            if (!IsOpenTab(frm.Text))
            {
                TabItem tabItem = tabControl1.CreateTab(frm.Text);
                TabControlPanel tcp = new TabControlPanel();
                tabItem.AttachedControl = tcp;
                tcp.TabItem = tabItem;
                tcp.Dock = DockStyle.Fill;
                tcp.Name = frm.Name + "Tab";

                frm.TopLevel = false;
                frm.Dock = DockStyle.Fill;
                frm.FormBorderStyle = FormBorderStyle.None;
                frm.Show();
                tcp.Controls.Add(frm);

                tabControl1.Controls.Add(tcp);
                tabControl1.SelectedTab = tabItem;
            }
        }

        /// <summary>
        ///  检查是否已打开某个子窗体
        /// </summary>
        /// <param name="tabName"></param>
        /// <returns></returns>
        private bool IsOpenTab(string tabName)
        {
            bool isOpened = false;

            foreach (TabItem tab in tabControl1.Tabs)
            {
                if (tab.Text.Trim() == tabName.Trim())
                {
                    isOpened = true;
                    tabControl1.SelectedTab = tab;
                    break;
                }
            }
            return isOpened;
        }

        private void tabControl1_TabRemoved(object sender, EventArgs e)
        {
            //tabControl1.Visible = false;
            int Count = this.tabControl1.Tabs.Count;
            if (Count == 0)
                this.tabControl1.Visible = false;
        }

 

DotNetBar-tabcontrol

标签:color   logs   string   text   add   blog   turn   ==   level   

原文地址:http://www.cnblogs.com/wangyinlon/p/7465849.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!