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

Getting Started with WinForms RepeatButton

You can add RadRepeatButton either at design time or at run time:

Design Time

  1. To add a RadRepeatButton to your form, drag a RadRepeatButton from the toolbox onto the surface of the form designer.
  2. In the Properties section in Visual Studio you can change the Text property.
  3. Double click the RadRepeatButton at design time in order to generate the Click event handler.
  4. Click F5 to start the application.

Run Time

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

Adding a RadButton at runtime

RadRepeatButton repeatButton = new RadRepeatButton();
repeatButton.Text = "Increase value";
this.Controls.Add(repeatButton);

Dim repeatButton As New RadRepeatButton()
repeatButton.Text = "Increase value"
Me.Controls.Add(repeatButton)

Working with RadRepeatButton

In addition to the standard properties shared by all buttons, notice a new property named Interval. This property determines the time, in milliseconds, between button click events after the control begins repeating events. The default value is 33.

To begin the repeat process, use the ButtonClick event instead of Click. To create an event handler for this event, change the filter in the Property Grid to Events and find the entry for ButtonClick. Double-click in the empty value drop-down list for the property to have the designer create a method to handle ButtonClick.

The following code illustrates the use of a RadRepeatButton to manipulate a ProgressBar control. At each interval the ProgressBar value will increment. You do not need to write any additional code to handle the repeating event. As long as the mouse button is pressed down on the RepeatButton control, the code in the ButtonClick event handler will run at each interval.

void radRepeatButton1_Click(object sender, EventArgs e)
{
    if (radProgressBar1.Value1 < radProgressBar1.Maximum)
    {
        radProgressBar1.Value1++;
    }
    else
    {
        radProgressBar1.Value1 = radProgressBar1.Minimum;
    }
}

Private Sub radRepeatButton1_Click(ByVal sender As Object, ByVal e As EventArgs)
    If radProgressBar1.Value1 < radProgressBar1.Maximum Then
        System.Math.Max(System.Threading.Interlocked.Increment(radProgressBar1.Value1), radProgressBar1.Value1 - 1)
    Else
        radProgressBar1.Value1 = radProgressBar1.Minimum
    End If
End Sub

WinForms RadRepeatButton Overview

Telerik UI for WinForms Learning Resources

In this article