Nasıl yapılır: Denetim İşleme Sınıfı Kullanma

Bu örnek, birleşik giriş kutusu ComboBoxRenderer denetimine açılan oku işlemek için sınıfının nasıl kullanılageldi? Örnekte basit bir özel OnPaint denetimin yöntemi yer almaktadır. özelliği, ComboBoxRenderer.IsSupported uygulama pencerelerinin istemci alanında görsel stillerin etkin olup olmadığını belirlemek için kullanılır. Görsel stilleri etkinse yöntem, açılan oku görsel stillerle işler; aksi takdirde yöntem açılan oku klasik stilde ComboBoxRenderer.DrawDropDownButtonControlPaint.DrawComboButton Windows işler.

Örnek

    // Render the drop-down arrow with or without visual styles.
protected:
    virtual void OnPaint(PaintEventArgs^ e) override
    {
        __super::OnPaint(e);

        if (!ComboBoxRenderer::IsSupported)
        {
            ControlPaint::DrawComboButton(e->Graphics,
                this->ClientRectangle, ButtonState::Normal);
        }
        else
        {
            ComboBoxRenderer::DrawDropDownButton(e->Graphics,
                this->ClientRectangle, ComboBoxState::Normal);
        }
    }
// Render the drop-down arrow with or without visual styles.
protected override void OnPaint(PaintEventArgs e)
{
    base.OnPaint(e);

    if (!ComboBoxRenderer.IsSupported)
    {
        ControlPaint.DrawComboButton(e.Graphics,
            this.ClientRectangle, ButtonState.Normal);
    }
    else
    {
        ComboBoxRenderer.DrawDropDownButton(e.Graphics,
            this.ClientRectangle, ComboBoxState.Normal);
    }
}
' Render the drop-down arrow with or without visual styles.
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
    MyBase.OnPaint(e)

    If Not ComboBoxRenderer.IsSupported Then
        ControlPaint.DrawComboButton(e.Graphics, _
            Me.ClientRectangle, ButtonState.Normal)
    Else
        ComboBoxRenderer.DrawDropDownButton(e.Graphics, _
            Me.ClientRectangle, ComboBoxState.Normal)
    End If
End Sub

Kod Derleniyor

Bu örnek şunları gerektirir:

Ayrıca bkz.