Export (0) Print
Expand All

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.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Show:
© 2015 Microsoft