public ScrollableControl() { hscrollbar = new HorizontalScrollBar { Visible = false }; hscrollbar.ValueChanged += HandleScroll; hscrollbar.Scroll += (o, e) => OnScroll(e); vscrollbar = new VerticalScrollBar { Visible = false }; vscrollbar.ValueChanged += HandleScroll; vscrollbar.Scroll += (o, e) => OnScroll(e); sizegrip = new SizeGrip { Visible = false }; Controls.AddImplicitControlRange(sizegrip, hscrollbar, vscrollbar); SizeChanged += (o, e) => Recalculate(true); VisibleChanged += (o, e) => Recalculate(true); }
/// <summary> /// Initializes a new instance of the ScrollControl class. /// </summary> public ScrollControl() { sizegrip = Controls.AddImplicitControl( new SizeGrip { Visible = false, Cursor = Cursors.Arrow }); hscrollbar = Controls.AddImplicitControl( new HorizontalScrollBar { Visible = false, Dock = DockStyle.Bottom, Cursor = Cursors.Arrow }); vscrollbar = Controls.AddImplicitControl( new VerticalScrollBar { Visible = false, Dock = DockStyle.Right, Cursor = Cursors.Arrow }); }