ProgressBarRenderer.DrawVerticalBar(Graphics, Rectangle) 方法

定义

绘制一个垂直填充的空白进度栏控件。

public:
 static void DrawVerticalBar(System::Drawing::Graphics ^ g, System::Drawing::Rectangle bounds);
public static void DrawVerticalBar (System.Drawing.Graphics g, System.Drawing.Rectangle bounds);
static member DrawVerticalBar : System.Drawing.Graphics * System.Drawing.Rectangle -> unit
Public Shared Sub DrawVerticalBar (g As Graphics, bounds As Rectangle)

参数

g
Graphics

Graphics,用于绘制进度栏。

bounds
Rectangle

Rectangle,它指定进度栏的边界。

例外

操作系统不支持视觉样式。

  • 或 -

用户在操作系统中禁用视觉样式。

  • 或 -

视觉样式不应用于应用程序窗口的工作区。

示例

下面的代码示例使用 DrawVerticalBar 自定义控件 OnPaint 方法中的方法绘制空进度栏。 此代码示例是为类提供的大型示例的 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

注解

使用此方法之前,应验证 IsSupported 属性是否 true返回 。

适用于