This documentation is archived and is not being maintained.

CheckBoxRenderer.GetGlyphSize Method

Returns the size of the check box glyph.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public static Size GetGlyphSize(
	Graphics g,
	CheckBoxState state
)

Parameters

g
Type: System.Drawing.Graphics
The Graphics this operation will use.
state
Type: System.Windows.Forms.VisualStyles.CheckBoxState
One of the CheckBoxState values that specifies the visual state of the check box.

Return Value

Type: System.Drawing.Size
A Size that represents the size of the check box glyph.

The size of the check box glyph is determined by the current visual style of the operating system.

The following code example uses the GetGlyphSize method to determine the bounds of the check box text. This code example is part of a larger example provided for the CheckBoxRenderer class.


// Calculate the text bounds, exluding the check box.
public Rectangle TextRectangle
{
    get
    {
        using (Graphics g = this.CreateGraphics())
        {
            textRectangleValue.X = ClientRectangle.X +
                CheckBoxRenderer.GetGlyphSize(g,
                CheckBoxState.UncheckedNormal).Width;
            textRectangleValue.Y = ClientRectangle.Y;
            textRectangleValue.Width = ClientRectangle.Width -
                CheckBoxRenderer.GetGlyphSize(g,
                CheckBoxState.UncheckedNormal).Width;
            textRectangleValue.Height = ClientRectangle.Height;
        }

        return textRectangleValue;
    }
}


.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: