WinForms › Scroll Bars › IScrollBarThumbRenderer
IScrollBarThumbRenderer
interface.NET 6 / 8 / 10.NET Framework 4.8Binarymission.WinForms.Controls.ScrollBars
Draws a scroll bar's thumb. Implement it and assign it to ScrollBarBase.ScrollBarThumbRenderer
to replace the built-in thumb; its size and position still come from the bar.
public interface IScrollBarThumbRenderer
Examples
sealed class PillThumbRenderer : IScrollBarThumbRenderer
{
public void Draw(Graphics g, Rectangle bounds, ControlVisualState state)
{
var colour = state == ControlVisualState.Normal ? Color.Silver : Color.Gray;
using (var brush = new SolidBrush(colour))
{
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
g.FillRectangle(brush, Rectangle.Inflate(bounds, -3, -3));
}
}
}
messagesBar.ScrollBarThumbRenderer = new PillThumbRenderer();Members at a glance
| Methods | |
|---|---|
Draw | Draws the thumb into its bounds. |
Methods
Draw
void Draw(Graphics graphicsInstanceToDrawOnto, Rectangle drawingBounds, ControlVisualState controlVisualState)
Draws the thumb into its bounds.
Parameters
graphicsInstanceToDrawOnto- The bar's drawing surface.
drawingBounds- The thumb's bounds in the bar's client coordinates.
controlVisualState- Whether the thumb is idle, under the pointer or being dragged.