共用方式為


ProgressBarRenderer.DrawVerticalChunks(Graphics, Rectangle) 方法

定義

會抽取一組進度條碎片,填滿垂直進度條。

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

參數

g
Graphics

它們 Graphics 用來繪製進度條。

bounds
Rectangle

Rectangle那個則指定了進度條塊要填滿的範圍。

例外狀況

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

-或-

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

-或-

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

範例

以下程式碼範例使用事件處理程序中的方法DrawVerticalChunksTimer.Tick來繪製進度條的每個增量。 此程式碼範例是本類別更大範例 ProgressBarRenderer 的一部分。

    // Handle the timer tick; draw each progressively larger rectangle.
private:
    void progressTimer_Tick(Object^ myObject, EventArgs^ e)
    {
        if (ticks < NumberChunks)
        {
            Graphics^ g = this->CreateGraphics();
            ProgressBarRenderer::DrawVerticalChunks(g,
                progressBarRectangles[ticks]);
            ticks++;
        }
        else
        {
            progressTimer->Enabled = false;
        }
    }
// Handle the timer tick; draw each progressively larger rectangle.
private void progressTimer_Tick(Object myObject, EventArgs e)
{
    if (ticks < NumberChunks)
    {
        using (Graphics g = this.CreateGraphics())
        {
            ProgressBarRenderer.DrawVerticalChunks(g,
                progressBarRectangles[ticks]);
            ticks++;
        }
    }
    else
    {
        progressTimer.Enabled = false;
    }
}
' Handle the timer tick; draw each progressively larger rectangle.
Private Sub progressTimer_Tick(ByVal myObject As [Object], ByVal e As EventArgs) 
    If ticks < NumberChunks Then
        Dim g As Graphics = Me.CreateGraphics()
        Try
            ProgressBarRenderer.DrawVerticalChunks(g, progressBarRectangles(ticks))
            ticks += 1
        Finally
            g.Dispose()
        End Try
    Else
        progressTimer.Enabled = False
    End If

End Sub

備註

此方法繪製的每個進度條塊都跨越參數寬 bounds 度。 繪製進度條的數量由 的 bounds 高度決定,返回的值則由 ChunkSpaceThicknessChunkThickness

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

適用於