Share via


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

Bu örnekte, birleşik giriş kutusu denetiminin ComboBoxRenderer açılan okunu işlemek için sınıfın nasıl kullanılacağı gösterilmektedir. Örnek, basit bir özel denetimin yönteminden oluşur OnPaint . ComboBoxRenderer.IsSupported özelliği, uygulama pencerelerinin istemci alanında görsel stillerin etkinleştirilip etkinleştirilmediğini belirlemek için kullanılır. Görsel stiller etkinse, ComboBoxRenderer.DrawDropDownButton yöntemi açılan oku görsel stilleriyle işler; aksi takdirde, ControlPaint.DrawComboButton yöntem açılan oku klasik Windows stilinde 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.