CheckBoxRenderer.GetGlyphSize(Graphics, CheckBoxState) Méthode

Définition

Retourne la taille du glyphe de la case à cocher.

public:
 static System::Drawing::Size GetGlyphSize(System::Drawing::Graphics ^ g, System::Windows::Forms::VisualStyles::CheckBoxState state);
public static System.Drawing.Size GetGlyphSize (System.Drawing.Graphics g, System.Windows.Forms.VisualStyles.CheckBoxState state);
static member GetGlyphSize : System.Drawing.Graphics * System.Windows.Forms.VisualStyles.CheckBoxState -> System.Drawing.Size
Public Shared Function GetGlyphSize (g As Graphics, state As CheckBoxState) As Size

Paramètres

g
Graphics

Graphics que cette opération va utiliser.

state
CheckBoxState

Une des valeurs CheckBoxState qui spécifie l'état visuel de la case à cocher.

Retours

Size qui représente la taille du glyphe de la case à cocher.

Exemples

L’exemple de code suivant utilise la GetGlyphSize méthode pour déterminer les limites du texte de la case à cocher. Cet exemple de code fait partie d’un exemple plus grand fourni pour la CheckBoxRenderer classe .

// Calculate the text bounds, exluding the check box.
Rectangle getTextRectangle()
{
    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;

    delete g;
    return textRectangleValue;
}
// 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;
    }
}
' Calculate the text bounds, exluding the check box.
Public ReadOnly Property TextRectangle() As Rectangle
    Get
        Using g As Graphics = Me.CreateGraphics()
            With textRectangleValue
                .X = Me.ClientRectangle.X + _
                    CheckBoxRenderer.GetGlyphSize(g, _
                    CheckBoxState.UncheckedNormal).Width
                .Y = Me.ClientRectangle.Y
                .Width = Me.ClientRectangle.Width - _
                    CheckBoxRenderer.GetGlyphSize(g, _
                    CheckBoxState.UncheckedNormal).Width
                .Height = Me.ClientRectangle.Height
            End With
        End Using
        Return textRectangleValue
    End Get
End Property

Remarques

La taille du glyphe de case à cocher est déterminée par le style visuel actuel du système d’exploitation.

S’applique à