System.Windows.Forms.CustomTabControl.GetPageBounds C# (CSharp) Method

GetPageBounds() public method

public GetPageBounds ( int index ) : Rectangle
index int
return System.Drawing.Rectangle
        public Rectangle GetPageBounds(int index)
        {
            Rectangle pageBounds = this.TabPages[index].Bounds;
            pageBounds.Width += 1;
            pageBounds.Height += 1;
            pageBounds.X -= 1;
            pageBounds.Y -= 1;

            if (pageBounds.Bottom > this.Height - 4){
                pageBounds.Height -= (pageBounds.Bottom - this.Height + 4);
            }
            return pageBounds;
        }

Usage Example

Example #1
0
        protected virtual void EnsureFirstTabIsInView(ref Rectangle tabBounds, int index)
        {
            // Adjust first tab in the row to align with tabPage.
            // Make sure we only reposition visible tabs, as we may have scrolled out of view.

            bool firstTabinRow = _TabControl.IsFirstTabInRow(index);

            if (firstTabinRow)
            {
                if (_TabControl.Alignment <= TabAlignment.Bottom)
                {
                    if (_TabControl.RightToLeftLayout)
                    {
                        if (tabBounds.Left < _TabControl.Right)
                        {
                            int tabPageRight = _TabControl.GetPageBounds(index).Right;

                            if (tabBounds.Right > tabPageRight)
                            {
                                tabBounds.Width -= (tabBounds.Right - tabPageRight);
                            }
                        }
                    }
                    else
                    {
                        if (tabBounds.Right > 0)
                        {
                            int tabPageX = _TabControl.GetPageBounds(index).X;

                            if (tabBounds.X < tabPageX)
                            {
                                tabBounds.Width -= (tabPageX - tabBounds.X);
                                tabBounds.X      = tabPageX;
                            }
                        }
                    }
                }
                else
                {
                    if (_TabControl.RightToLeftLayout)
                    {
                        if (tabBounds.Top < _TabControl.Bottom)
                        {
                            int tabPageBottom = _TabControl.GetPageBounds(index).Bottom;

                            if (tabBounds.Bottom > tabPageBottom)
                            {
                                tabBounds.Height -= (tabBounds.Bottom - tabPageBottom);
                            }
                        }
                    }
                    else
                    {
                        if (tabBounds.Bottom > 0)
                        {
                            int tabPageY = _TabControl.GetPageBounds(index).Location.Y;

                            if (tabBounds.Y < tabPageY)
                            {
                                tabBounds.Height -= (tabPageY - tabBounds.Y);
                                tabBounds.Y       = tabPageY;
                            }
                        }
                    }
                }
            }
        }