WinForms › Extended Group Box
Extended Group Box
.NET Framework 4.8.NET 6 / 8 / 10v3.0.0WinForms
A group box with a styled frame: a gradient or solid body, a solid, dotted or rounded border, and a
header band with its own background, border and font – a drop-in replacement for
GroupBox.
4public types
48public members
1namespaces
Assembly
| Assembly | Binarymission.WinForms.Controls.AdvancedGroupBox.dll |
| Root namespace | Binarymission.WinForms.Controls.Containers |
| Target frameworks | .NET Framework 4.8, .NET 6 / 8 / 10 |
Overview
What it is for
Use it wherever a form groups related fields – "Delivery address", "Payment", "Account
settings" – and the stock group box looks too plain. It is a GroupBox, so it keeps the
container behaviour, the tab order and the designer support; only the drawing is replaced.
The parts of the frame
- Body – filled from half-way down the header to the bottom, with a gradient
from
BackgroundBrushColor1toBackgroundBrushColor2atLinearGradientBrushGradientAngle, or withControl.BackColorwhenIsBackgroundDrawingUsingLinerGradientBrushisfalse. - Border –
BorderColoratBorderThickness, drawn as a line or as dashes (ControlBorderStyle), optionally with rounded corners (ShouldDrawRoundedCorners,RoundedCornerTargets,RoundedCornersAngle). - Header – the control's
Control.TextinHeaderFontandHeaderForeColor, on a band with its own gradient or solid background and border, placed byHeaderAlignment.
Good to know
- While the body is a gradient, a child control added with the group box's own
Control.BackColoris given a transparent background, so labels and check boxes do not paint solid bands across the gradient. A child whose back colour was set to something else is left alone. - Metrics – margins, thicknesses, dash lengths, corner size – are in logical pixels and are scaled for the display the control is on.
- The header and the body read
HeaderFont, notControl.Font;Control.Fontis still the font children inherit.
Getting started
using System.Drawing;
using System.Windows.Forms;
using Binarymission.WinForms.Controls.Containers;
public class CheckoutForm : Form
{
public CheckoutForm()
{
Text = "Checkout";
ClientSize = new Size(380, 220);
var deliveryGroup = new AdvancedGroupBox
{
Text = "Delivery address",
Location = new Point(12, 12),
Size = new Size(356, 150),
HeaderFont = new Font("Segoe UI", 9.75f, FontStyle.Bold),
HeaderForeColor = Color.White,
HeaderBackgroundColor1 = Color.SteelBlue,
HeaderBackgroundColor2 = Color.MidnightBlue,
HeaderBorderColor = Color.MidnightBlue,
BackgroundBrushColor1 = Color.White,
BackgroundBrushColor2 = Color.AliceBlue,
BorderColor = Color.SteelBlue,
ShouldDrawRoundedCorners = true,
RoundedCornerTargets = GroupBoxCornerTargets.BottomLeft | GroupBoxCornerTargets.BottomRight,
RoundedCornersAngle = 16
};
deliveryGroup.Controls.Add(new Label { Text = "Postcode", Location = new Point(16, 40), AutoSize = true });
deliveryGroup.Controls.Add(new TextBox { Location = new Point(100, 36), Width = 120 });
deliveryGroup.Controls.Add(new CheckBox { Text = "Same as billing address", Location = new Point(16, 76), AutoSize = true });
Controls.Add(deliveryGroup);
}
}API reference
Binarymission.WinForms.Controls.Containers
class AdvancedGroupBox | A group box with a styled frame: a gradient or solid body, a solid, dotted or rounded border, and a header band with its own background, border and font - a drop-in replacement for GroupBox. |
enum GroupBoxBorderStyle | The ways an AdvancedGroupBox can draw its frame. |
enum GroupBoxCornerTargets | The corners of an AdvancedGroupBox frame that are rounded. Combine values with | . |
enum GroupBoxHeaderAlignment | Where the header of an AdvancedGroupBox sits along its top edge. |