RadioButtonRenderer.GetGlyphSize(Graphics, RadioButtonState) Method

Definition

Returns the size, in pixels, of the option button (also known as a radio button) glyph.

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

Parameters

g
Graphics

The Graphics used to draw the option button.

state
RadioButtonState

One of the RadioButtonState values that specifies the visual state of the option button.

Returns

A Size that represents the size, in pixels, of the option button glyph.

Examples

The following code example uses the GetGlyphSize method to determine the bounds of the option button text. This code example is part of a larger example provided for the RadioButtonRenderer class.

C#
// Define the text bounds so that the text rectangle 
// does not include the radio button.
public Rectangle TextRectangle
{
    get
    {
        using (Graphics g = this.CreateGraphics())
        {
            textRectangleValue.X = ClientRectangle.X +
                RadioButtonRenderer.GetGlyphSize(g,
                RadioButtonState.UncheckedNormal).Width;
            textRectangleValue.Y = ClientRectangle.Y;
            textRectangleValue.Width = ClientRectangle.Width -
                RadioButtonRenderer.GetGlyphSize(g,
                RadioButtonState.UncheckedNormal).Width;
            textRectangleValue.Height = ClientRectangle.Height;
        }

        return textRectangleValue;
    }
}

Remarks

This value is determined by the current visual style of the operating system.

Applies to

Producto Versiones
.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, 10