public Rectangle CalcPopupRect(Rectangle filterButtonRect)
        {
            Rectangle popupRect = new Rectangle();

            int      maxWidth   = 0;
            int      maxHeight  = 0;
            Graphics graphics   = this.CreateGraphics();
            int      itemHeight = (int)Math.Round(graphics.MeasureString("0", this.filterItemsList.Font).Height) + 3;

            for (int i = 0; i < this.filterItemsList.ItemCount; i++)
            {
                SizeF szText    = graphics.MeasureString(this.filterItemsList.Items[i].ToString(), this.filterItemsList.Font);
                int   itemWidth = (int)Math.Round(szText.Width);

                if (itemWidth > maxWidth)
                {
                    maxWidth = itemWidth;
                }

                if (i < 20)
                {
                    maxHeight += itemHeight;
                }
            }
            maxWidth += 10;

            if (maxWidth > ownerTreeList.Width / 2)
            {
                maxWidth = ownerTreeList.Width / 2;
            }

            DevExpress.XtraEditors.VScrollBar vScroll = new DevExpress.XtraEditors.VScrollBar();
            int vScrollWidth = vScroll.Width;

            vScroll.Dispose();

            if (itemHeight * this.filterItemsList.ItemCount > maxHeight)
            {
                maxWidth += vScrollWidth;
            }

            popupRect.X        = filterButtonRect.X;
            popupRect.Y        = filterButtonRect.Bottom;
            popupRect.Location = ownerTreeList.PointToScreen(popupRect.Location);

            popupRect.Width  = maxWidth;
            popupRect.Height = maxHeight;

            Rectangle screenWorkingArea = Screen.GetWorkingArea(popupRect.Location);

            if (popupRect.Right > screenWorkingArea.Right)
            {
                popupRect.X -= popupRect.Right - screenWorkingArea.Right;
            }

            if (popupRect.Bottom > screenWorkingArea.Bottom)
            {
                popupRect.Y = ownerTreeList.PointToScreen(filterButtonRect.Location).Y - popupRect.Height;
            }

            return(popupRect);
        }