Ejemplo n.º 1
0
        private void adjustScrollbars()
        {
            // Hide scrollbar when not needed.
            // http://devexpress.com/Support/Center/p/Q96633.aspx

            // Looking for a Windows Forms solution?
            // http://stackoverflow.com/questions/73110/how-can-i-show-scrollbars-on-a-system-windows-forms-textbox-only-when-the-text-d

            var vi = (MemoEditViewInfo)_edit.GetViewInfo();

            using (var cache = new GraphicsCache(_edit.CreateGraphics()))
            {
                var h = ((IHeightAdaptable)vi).CalcHeight(
                    cache,
                    vi.MaskBoxRect.Width);

                var args = new ObjectInfoArgs
                {
                    Bounds = new Rectangle(0, 0, vi.ClientRect.Width, h)
                };

                var rect = vi.BorderPainter.CalcBoundsByClientRectangle(args);
                _edit.Properties.ScrollBars =
                    rect.Height > _edit.Height
                                                ? ScrollBars.Vertical
                                                : ScrollBars.None;
            }
        }
Ejemplo n.º 2
0
        public static void SetScrollBarVisibility(this MemoEdit memoEdit)
        {
            MemoEditViewInfo vi    = memoEdit.GetViewInfo() as MemoEditViewInfo;
            GraphicsCache    cache = new GraphicsCache(memoEdit.CreateGraphics());
            int            h       = (vi as IHeightAdaptable).CalcHeight(cache, vi.MaskBoxRect.Width);
            ObjectInfoArgs args    = new ObjectInfoArgs();

            args.Bounds = new Rectangle(0, 0, vi.ClientRect.Width, h);
            Rectangle rect = vi.BorderPainter.CalcBoundsByClientRectangle(args);

            cache.Dispose();
            memoEdit.Properties.ScrollBars = rect.Height > memoEdit.Height ?
                                             ScrollBars.Vertical : ScrollBars.None;
        }