ProgressBarRenderer.IsSupported 属性

定义

获取一个值,该值指示 ProgressBarRenderer 类是否可用于以视觉样式绘制进度栏控件。

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

属性值

Boolean

如果用户已在操作系统中启用了视觉样式,并将视觉样式应用于应用程序窗口的工作区,则为 true;否则为 false

示例

下面的代码示例使用 IsSupported 属性来确定是否调用 DrawVerticalBar 该方法。 此代码示例是为类提供的大型示例的 ProgressBarRenderer 一部分。

    // Draw the progress bar in its normal state.
protected:
    virtual void OnPaint(PaintEventArgs^ e) override
    {
        __super::OnPaint(e);

        if (ProgressBarRenderer::IsSupported)
        {
            ProgressBarRenderer::DrawVerticalBar(e->Graphics, 
                ClientRectangle);
            this->Parent->Text = "VerticalProgressBar Enabled";
        }
        else
        {
            this->Parent->Text = "VerticalProgressBar Disabled";
        }
    }
// Draw the progress bar in its normal state.
protected override void OnPaint(PaintEventArgs e)
{
    base.OnPaint(e);

    if (ProgressBarRenderer.IsSupported)
    {
        ProgressBarRenderer.DrawVerticalBar(e.Graphics,
            ClientRectangle);
        this.Parent.Text = "VerticalProgressBar Enabled";
    }
    else
    {
        this.Parent.Text = "VerticalProgressBar Disabled";
    }
}
' Draw the progress bar in its normal state.
Protected Overrides Sub OnPaint(ByVal e As PaintEventArgs) 
    MyBase.OnPaint(e)
    
    If ProgressBarRenderer.IsSupported Then
        ProgressBarRenderer.DrawVerticalBar(e.Graphics, ClientRectangle)
        Me.Parent.Text = "VerticalProgressBar Enabled"
    Else
        Me.Parent.Text = "VerticalProgressBar Disabled"
    End If

End Sub

注解

如果此属性为false,则此类的方法和属性将引发 。InvalidOperationException

适用于

另请参阅