Esempio n. 1
0
        public void ActivePage(Control page)
        {
            if (page == null)
            {
                return;
            }

            TabBar.SelectByTag(page);
            SelectedIndex = ControlContainer.Controls.IndexOf(page);
            if (page.Bounds != ControlContainer.ClientRectangle)
            {
                page.Bounds = ControlContainer.ClientRectangle;
            }
            //page.Dock = DockStyle.Fill;

            foreach (Control control in ControlContainer.Controls)
            {
                control.Visible = control == page;
            }
        }
Esempio n. 2
0
        public void ActivePage(Control page)
        {
            if (page == null)
            {
                return;
            }

            if (TabBar.SelectByTag(page))
            {
                //HidePages();

                // 注意一下操作的顺序, 可以减少切换闪烁

                if (!Controls.Contains(page))
                {
                    page.Dock   = DockStyle.Fill;
                    page.Bounds = DisplayRectangle;
                    Controls.Add(page);
                }

                foreach (Control ctrl in Controls)
                {
                    if (ctrl != page && ctrl != TabBar)
                    {
                        Controls.Remove(ctrl);
                    }
                }

                if (this.ContainsFocus && !page.ContainsFocus && page.CanFocus)
                {
                    page.Focus();
                }

                SelectedIndex = TabPages.IndexOf(page);
            }
        }