CheckBoxRenderer.GetGlyphSize(Graphics, CheckBoxState) Metodo

Definizione

Restituisce la dimensione dell'icona della casella di controllo.

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

Parametri

g
Graphics

Oggetto Graphics utilizzato da questa operazione.

state
CheckBoxState

Uno dei valori di CheckBoxState che specifica lo stato di visualizzazione della casella di controllo.

Restituisce

Oggetto Size che rappresenta la dimensione dell'icona della casella di controllo.

Esempio

Nell'esempio di codice seguente viene usato il GetGlyphSize metodo per determinare i limiti del testo della casella di controllo. Questo esempio di codice fa parte di un esempio più grande fornito per 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

Commenti

La dimensione del glifo della casella di controllo è determinata dallo stile visivo corrente del sistema operativo.

Si applica a