次の方法で共有


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

例外

オペレーティング システムでは、ビジュアル スタイルはサポートされていません。

-又は-

ビジュアル スタイルは、オペレーティング システムのユーザーによって無効になります。

-又は-

ビジュアル スタイルは、アプリケーション ウィンドウのクライアント領域には適用されません。

次のコード例では、Timer.Tick イベント ハンドラーのDrawVerticalChunks メソッドを使用して、進行状況バーの各インクリメントを描画します。 このコード例は、 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を返していることを確認する必要があります。

適用対象