共用方式為


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 個決定了進度條的範圍。

例外狀況

作業系統不支援視覺樣式。

-或-

視覺樣式則由使用者在作業系統中停用。

-或-

視覺樣式不會套用到應用程式視窗的用戶端區域。

範例

以下程式碼範例使用OnPaint自訂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

備註

在使用此方法之前,您應該確認屬性是否 IsSupported 返回 true

適用於