New to Telerik UI for WinForms? Download free 30-day trial

Getting Started with WinForms WaitingBar

  • To add a RadWaitingBar to your form, drag a RadWaitingBar from the toolbox onto the surface of the form designer.

  • To programmatically add a RadWaitingBar to a form, create a new instance of a RadWaitingBar, and add it to the form Controls collection.

Adding a RadWaitingBar at runtime

RadWaitingBar radWaitingBar = new RadWaitingBar();
radWaitingBar.WaitingStyle = Telerik.WinControls.Enumerations.WaitingBarStyles.Dash;
radWaitingBar.WaitingDirection = ProgressOrientation.Left;
this.Controls.Add(radWaitingBar);

Dim radWaitingBar As New RadWaitingBar()
radWaitingBar.WaitingStyle = Telerik.WinControls.Enumerations.WaitingBarStyles.Dash
radWaitingBar.WaitingDirection = ProgressOrientation.Left
Me.Controls.Add(radWaitingBar)

The following tutorial illustrates how to start and stop the animation of RadWaitingBar:

1. Place a RadWaitingBar control and a RadButton control on a form.

2. Select the RadWaitingBar control.

3. In the Properties window set the WaitingDirection property to Bottom.

4. Resize the RadWaitingBar so that its height is larger than its width.

5. Select the RadButton control.

6. Set the Text property to Start.

7. In the Properties window click the events button.

8. Double-click the Click event.

9. Replace the automatically-generated event handler with this code:

RadButton's Click event handler

private void radButton1_Click(object sender, EventArgs e)
{
    if (radWaitingBar1.IsWaiting)
    {
        radWaitingBar1.StopWaiting();
        this.radButton1.Text = "Start";
    }
    else
    {
        radWaitingBar1.StartWaiting();
        this.radButton1.Text = "Stop";
    }
}

Private Sub radButton1_Click(ByVal sender As Object, ByVal e As EventArgs)
    If RadWaitingBar1.IsWaiting Then
        RadWaitingBar1.StopWaiting()
        Me.RadButton1.Text = "Start"
    Else
        RadWaitingBar1.StartWaiting()
        Me.RadButton1.Text = "Stop"
    End If
End Sub

10. Press F5 to run the project.

11. Click the Start button to start and stop the animation.

WinForms RadWaitingBar Start Stop Animation

Adding Indicator Elements programmatically

The following example demonstrates how to add DotsLineWaitingBarIndicatorElements in a RadWaitingBar with WaitingBarStyles.DotsSpinner:

WinForms RadWaitingBar Adding Indicator Elements programmatically

RadWaitingBar radWaitingBar1 = new RadWaitingBar();
radWaitingBar1.Size = new System.Drawing.Size(200, 200);
radWaitingBar1.WaitingStyle = Telerik.WinControls.Enumerations.WaitingBarStyles.DotsSpinner;
radWaitingBar1.StartWaiting();
int radius = 20;
int elementCount = 5;
for (int i = 0; i < 4; i++)
{
    radius += 10;
    elementCount += 1;
    DotsSpinnerWaitingBarIndicatorElement dsi = new DotsSpinnerWaitingBarIndicatorElement();
    radWaitingBar1.WaitingIndicators.Add(dsi);
    dsi.Radius = radius;
    dsi.ElementCount = elementCount;
    dsi.RotationDirection = (RotationDirection)(i % 2);
}
DotsLineWaitingBarIndicatorElement dli = new DotsLineWaitingBarIndicatorElement();
radWaitingBar1.WaitingIndicators.Add(dli);
dli.PositionOffset = new SizeF(0, 50);
DotsLineWaitingBarIndicatorElement dli1 = new DotsLineWaitingBarIndicatorElement();
radWaitingBar1.WaitingIndicators.Add(dli1);
dli1.WaitingDirection = Telerik.WinControls.ProgressOrientation.Left;
dli1.PositionOffset = new SizeF(0, -50);
DotsLineWaitingBarIndicatorElement dli2 = new DotsLineWaitingBarIndicatorElement();
radWaitingBar1.WaitingIndicators.Add(dli2);
dli2.WaitingDirection = Telerik.WinControls.ProgressOrientation.Bottom;
dli2.PositionOffset = new SizeF(50, 0);
DotsLineWaitingBarIndicatorElement dli4 = new DotsLineWaitingBarIndicatorElement();
radWaitingBar1.WaitingIndicators.Add(dli4);
dli4.WaitingDirection = Telerik.WinControls.ProgressOrientation.Top;
dli4.PositionOffset = new SizeF(-50, 0);
radWaitingBar1.Location = new Point(10, 10);
this.Controls.Add(radWaitingBar1);
radWaitingBar1.StartWaiting();

Dim radWaitingBar1 As New RadWaitingBar()
radWaitingBar1.Size = New System.Drawing.Size(200, 200)
radWaitingBar1.WaitingStyle = Telerik.WinControls.Enumerations.WaitingBarStyles.DotsSpinner
radWaitingBar1.StartWaiting()
Dim radius As Integer = 20
Dim elementCount As Integer = 5
For i As Integer = 0 To 3
    radius += 10
    elementCount += 1
    Dim dsi As New DotsSpinnerWaitingBarIndicatorElement()
    radWaitingBar1.WaitingIndicators.Add(dsi)
    dsi.Radius = radius
    dsi.ElementCount = elementCount
    dsi.RotationDirection = DirectCast(i Mod 2, RotationDirection)
Next
Dim dli As New DotsLineWaitingBarIndicatorElement()
radWaitingBar1.WaitingIndicators.Add(dli)
dli.PositionOffset = New SizeF(0, 50)
Dim dli1 As New DotsLineWaitingBarIndicatorElement()
radWaitingBar1.WaitingIndicators.Add(dli1)
dli1.WaitingDirection = Telerik.WinControls.ProgressOrientation.Left
dli1.PositionOffset = New SizeF(0, -50)
Dim dli2 As New DotsLineWaitingBarIndicatorElement()
radWaitingBar1.WaitingIndicators.Add(dli2)
dli2.WaitingDirection = Telerik.WinControls.ProgressOrientation.Bottom
dli2.PositionOffset = New SizeF(50, 0)
Dim dli4 As New DotsLineWaitingBarIndicatorElement()
radWaitingBar1.WaitingIndicators.Add(dli4)
dli4.WaitingDirection = Telerik.WinControls.ProgressOrientation.Top
dli4.PositionOffset = New SizeF(-50, 0)
radWaitingBar1.Location = New Point(10, 10)
Me.Controls.Add(radWaitingBar1)
radWaitingBar1.StartWaiting()

See Also

Telerik UI for WinForms Learning Resources

In this article