BinaryScrollablePanel
A scrolling, gradient-filled panel that fills the client area of a BinaryHeaderControl,
for pane content that can be longer than the pane.
public class BinaryScrollablePanel : Panel
Inherits from / implements: Panel
Remarks
What it is for
BinaryHeaderControl does not scroll (its BinaryHeaderControl.AutoScroll
is always false). Add one of these panels to the header control and put the pane's
controls on the panel: it scrolls when they extend beyond it, and is painted in the same colour scheme
as the header control so that the two look like one surface.
How it behaves
- At run time, inside a
BinaryHeaderControl, the panel docks to fill it; in any other parent itsControl.Dockis yours to set. In the designer, inside aBinaryHeaderControl, it is sized to the client area instead, so that the header control's frame stays clickable. - Placed in a
BinaryHeaderControl, it takes the header control'sColorScheme, and follows it when the header control's scheme changes. - The background is a gradient from
StartColorForGradientRenderingtoEndColorForGradientRendering, fixed to the visible area rather than scrolling with the content. - The mouse wheel scrolls the panel, as it does any scrolling panel.
Examples
var projectsPane = new BinaryHeaderControl { Dock = DockStyle.Right, Width = 280, HeaderText = "Projects" };
var scroller = new BinaryScrollablePanel();
int top = 8;
foreach (string project in new[] { "Website redesign", "Payroll migration", "Q3 audit", "Mobile app" })
{
scroller.Controls.Add(new CheckBox { Text = project, Left = 8, Top = top, Width = 220, BackColor = Color.Transparent });
top += 28;
}
projectsPane.Controls.Add(scroller); // fills the pane and takes its colour scheme
Controls.Add(projectsPane); // in the form's constructorSee also
Members at a glance
| Constructors | |
|---|---|
BinaryScrollablePanel | Initialises a new BinaryScrollablePanel with scrolling switched on, no border and a white
Control.BackColor. |
| Properties | |
ColorScheme | Gets or sets the built-in palette the panel's background gradient is drawn in. |
EndColorForGradientRendering | Gets or sets the colour the panel's background gradient ends with. |
GradientDrawingDirection | Gets or sets the direction in which the panel's background gradient runs. |
StartColorForGradientRendering | Gets or sets the colour the panel's background gradient starts with. |
| Methods | |
OnEnter | Raises the Control.Enter event, first redrawing the frame of the containing
BinaryHeaderControl when in the designer. |
OnMouseWheel | Scrolls the panel, raises the Control.MouseWheel event and redraws the background so
that the gradient stays fixed to the visible area. |
OnPaint | Paints the background gradient and raises the Control.Paint event. |
OnPaintBackground | Does nothing: the background gradient is painted in OnPaint, which avoids flicker. |
OnParentChanged | Fits the panel to a new BinaryHeaderControl parent – filling its client area and taking
its ColorScheme – and raises the Control.ParentChanged event. |
OnResize | Redraws the parent, if any, and raises the Control.Resize event. |
WndProc | Processes the panel's window messages, repainting the background as the panel scrolls so that the gradient stays fixed to the visible area. |
Constructors
BinaryScrollablePanel
Initialises a new BinaryScrollablePanel with scrolling switched on, no border and a white
Control.BackColor.
Remarks
The scheme colours are applied when the panel is added to a BinaryHeaderControl
or when ColorScheme is set; until then the gradient runs from
SystemColors.ControlDarkDark to white.
Properties
ColorScheme
Gets or sets the built-in palette the panel's background gradient is drawn in.
- Value
- The default is
ColorScheme.Blue; a panel added to aBinaryHeaderControltakes that control's scheme. - Default
Blue
Remarks
Choosing a scheme overwrites StartColorForGradientRendering and
EndColorForGradientRendering. With ColorScheme.None the
panel copies the background colours of the BinaryHeaderControl it is in, so that the two
match; outside a header control, ColorScheme.None leaves the colours
as they are.
The header control sets this property on its panels whenever its own scheme changes.
See also
EndColorForGradientRendering
Gets or sets the colour the panel's background gradient ends with.
- Value
- The default comes from
ColorScheme:RGB(195, 219, 249)for theColorScheme.Bluescheme. - Designer category
- Color
See also
GradientDrawingDirection
Gets or sets the direction in which the panel's background gradient runs.
- Value
- The default is
Vertical: fromStartColorForGradientRenderingat the top toEndColorForGradientRenderingat the bottom. - Designer category
- Drawing
StartColorForGradientRendering
Gets or sets the colour the panel's background gradient starts with.
- Value
- The default comes from
ColorScheme:RGB(128, 167, 225)for theColorScheme.Bluescheme. - Designer category
- Color
Remarks
The panel paints this gradient instead of Control.BackColor. Choosing a
ColorScheme, or adding the panel to a BinaryHeaderControl, overwrites the
colour, so set it afterwards.
See also
Methods
OnEnter
Raises the Control.Enter event, first redrawing the frame of the containing
BinaryHeaderControl when in the designer.
Parameters
e- The data for the event.
OnMouseWheel
Scrolls the panel, raises the Control.MouseWheel event and redraws the background so
that the gradient stays fixed to the visible area.
Parameters
e- The data for the event.
OnPaint
Paints the background gradient and raises the Control.Paint event.
Parameters
e- The data for the event.
Remarks
At run time, inside a BinaryHeaderControl, the panel is docked to fill it here if it
is not already.
OnPaintBackground
Does nothing: the background gradient is painted in OnPaint, which avoids flicker.
Parameters
pevent- The data for the event; not used.
OnParentChanged
Fits the panel to a new BinaryHeaderControl parent – filling its client area and taking
its ColorScheme – and raises the Control.ParentChanged event.
Parameters
e- The data for the event.
Remarks
In any other parent the panel is undocked.
OnResize
Redraws the parent, if any, and raises the Control.Resize event.
Parameters
e- The data for the event.
WndProc
Processes the panel's window messages, repainting the background as the panel scrolls so that the gradient stays fixed to the visible area.
Parameters
m- The window message to process.