HypernovaDesktop Components · docs
Binarymission
WinForms › Scrollable Panel

Scrollable Panel

.NET Framework 4.8.NET 6 / 8 / 10v3.0.0WinForms

A container that scrolls content larger than itself with the suite's themeable scroll bars, inside an optional border and drop shadow.

2public types
35public members
2namespaces

Assembly

AssemblyBinarymission.WinForms.Controls.ScrollerPanel.dll
Root namespaceBinarymission.WinForms.Controls.Containers
Target frameworks.NET Framework 4.8, .NET 6 / 8 / 10
Depends onBinaryMenu, BinaryScrollBars

Overview

What it is for

Use it where a form needs a scrolling region – a long order form, a dashboard of cards, a wide diagram – and the scroll bars should match the application's theme rather than the system's.

How it works

Build the content on an ordinary Panel at its full size and assign it to ContentHostingPanel. The scroller panel shows its VerticalScrollBar when the content is taller than the visible area and its HorizontalScrollBar when it is wider, and scrolls by moving the content panel. The controls on the content panel need know nothing about the scrolling.

The bars' ranges are the content's size in pixels: one arrow click, arrow key or wheel notch moves by ScrollSize, a page by the visible size. Whenever the content or the scroller panel is resized the bars are recalculated and their thumbs return to the start; the content keeps the offset it had.

Keyboard and mouse

With the focus, Up / Down / Left / Right scroll by ScrollSize and Page Up / Page Down by a page; the wheel scrolls vertically, and horizontally with Shift. The bars also offer their right-click menus.

Appearance

The frame – BorderStyle, BorderSize, BorderColor and the optional drop shadow – is drawn outside the client area. Theme the bars through VerticalScrollBar and HorizontalScrollBar; their thickness is in device pixels and follows the system scroll bar size (see ScrollBarBase).

Getting started

using Binarymission.WinForms.Controls.Containers;
using Binarymission.WinForms.Controls.ScrollBars;

// An order form far larger than the space it is shown in.
var orderForm = new Panel { Size = new Size(820, 1400), BackColor = Color.White };
orderForm.Controls.Add(new Label { Text = "Sales order SO-10482", Location = new Point(16, 16), AutoSize = true });
orderForm.Controls.Add(new DataGridView { Location = new Point(16, 48), Size = new Size(780, 600) });

var orderViewer = new ScrollerPanel
{
    Location = new Point(12, 12),
    Size = new Size(480, 360),
    BorderColor = Color.SteelBlue,
    ShouldDrawDropShadow = true,
    ScrollSize = new Size(16, 24),
    ContentHostingPanel = orderForm,
};

foreach (ScrollBarBase bar in new ScrollBarBase[] { orderViewer.VerticalScrollBar, orderViewer.HorizontalScrollBar })
{
    bar.ScrollBarRenderingConfigurator.ColorTheme = ColorTheme.OfficeBlue;
}

Controls.Add(orderViewer);

API reference

Binarymission.WinForms.Controls.Containers

class ScrollerPanelA container that scrolls content larger than itself with the suite's themeable scroll bars, inside an optional border and drop shadow.

Binarymission.WinForms.Controls.Containers.Designers

class ScrollablePanelControlDesignerDesign-time support for ScrollerPanel: it lets the panel be moved and resized, and shows a short how-to on the panel until a content panel is assigned.