CheckBoxRenderer.GetGlyphSize(Graphics, CheckBoxState) Method

Definition

Returns the size of the check box glyph.

public static System.Drawing.Size GetGlyphSize (System.Drawing.Graphics g, System.Windows.Forms.VisualStyles.CheckBoxState state);

Parameters

g
Graphics

The Graphics this operation will use.

state
CheckBoxState

One of the CheckBoxState values that specifies the visual state of the check box.

Returns

A Size that represents the size of the check box glyph.

Examples

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;
    }
}

Remarks

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

Applies to

Proizvod Verzije
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9