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 回 。

適用於