共用方式為


TextBoxRenderer.IsSupported 屬性

定義

取得值,指出 TextBoxRenderer 類別是否可用來繪製具有視覺化樣式的文字方塊。

public:
 static property bool IsSupported { bool get(); };
public static bool IsSupported { get; }
static member IsSupported : bool
Public Shared ReadOnly Property IsSupported As Boolean

屬性值

如果使用者在作業系統中已經啟用視覺化樣式,而且應用程式視窗的工作區中已經套用視覺化樣式,則為 true,否則為 false

範例

下列程式碼範例會 IsSupported 使用 屬性來判斷是否要使用 DrawTextBox 方法。 此程式碼範例是針對 類別提供的較大範例的 TextBoxRenderer 一部分。

    // Use DrawText with the current TextFormatFlags.

protected:
    virtual void OnPaint(PaintEventArgs^ e) override
    {
        __super::OnPaint(e);

        if (TextBoxRenderer::IsSupported)
        {
            TextBoxRenderer::DrawTextBox(e->Graphics, textBorder, this->Text,
                this->Font, textRectangle, textFlags, TextBoxState::Normal);

            this->Parent->Text = "CustomTextBox Enabled";
        }
        else
        {
            this->Parent->Text = "CustomTextBox Disabled";
        }
    }
// Use DrawText with the current TextFormatFlags.
protected override void OnPaint(PaintEventArgs e)
{
    base.OnPaint(e);

    if (TextBoxRenderer.IsSupported)
    {
        TextBoxRenderer.DrawTextBox(e.Graphics, textBorder, this.Text,
            this.Font, textRectangle, textFlags, TextBoxState.Normal);

        this.Parent.Text = "CustomTextBox Enabled";
    }
    else
    {
        this.Parent.Text = "CustomTextBox Disabled";
    }
}
' Use DrawText with the current TextFormatFlags.
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs)
    MyBase.OnPaint(e)

    If TextBoxRenderer.IsSupported Then
        TextBoxRenderer.DrawTextBox(e.Graphics, textBorder, Me.Text, _
            Me.Font, textRectangle, textFlags, TextBoxState.Normal)
        Me.Parent.Text = "CustomTextBox Enabled"
    Else
        Me.Parent.Text = "CustomTextBox Disabled"
    End If
End Sub

備註

如果這個屬性為 false ,則 DrawTextBox 方法會擲回 InvalidOperationException

適用於

另請參閱