HypernovaDesktop Components · docs
Binarymission
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

AssemblyBinarymission.WinForms.Controls.AdvancedGroupBox.dll
Root namespaceBinarymission.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

Good to know

  • While the body is a gradient, a child control added with the group box's own Control.BackColor is 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, not Control.Font; Control.Font is 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 AdvancedGroupBoxA 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 GroupBoxBorderStyleThe ways an AdvancedGroupBox can draw its frame.
enum GroupBoxCornerTargetsThe corners of an AdvancedGroupBox frame that are rounded. Combine values with | .
enum GroupBoxHeaderAlignmentWhere the header of an AdvancedGroupBox sits along its top edge.