RadioButtonRenderer.GetGlyphSize Method (Graphics, RadioButtonState)

 

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

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

public static Size GetGlyphSize(
	Graphics g,
	RadioButtonState state
)

Parameters

g
Type: System.Drawing.Graphics

The Graphics used to draw the option button.

state
Type: System.Windows.Forms.VisualStyles.RadioButtonState

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

Return Value

Type: System.Drawing.Size

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

This value 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 option button text. This code example is part of a larger example provided for the RadioButtonRenderer class.

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

.NET Framework
Available since 2.0
Return to top
Show: