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

Getting Started with WinForms Rating

Below are the basic steps needed to get started with RadRating control in Visual Studio:

1. Drag RadRating from the Visual Studio Toolbox to the form.

WinForms RadRating Getting Started

  1. Set the Caption to “The best movie ever”.

  2. Set the SelectionMode property to HalfItem.

  3. In the code behind subscribe to the ValueChanged event, where you can calculate and display the average rating:

Handling the ValueChanged event


double averageRating = 0;
int numberOfChanges = 0;

public RatingGettingStarted()
{
    InitializeComponent();

    this.radRating1.Caption = "The best movie ever";
    this.radRating1.Description = "Your rating:";
    this.radRating1.SelectionMode = Telerik.WinControls.UI.RatingSelectionMode.HalfItem;
    this.radRating1.ValueChanged += radRating1_ValueChanged;
}

private void radRating1_ValueChanged(object sender, EventArgs e)
{
    Telerik.WinControls.UI.RadRating rating = sender as Telerik.WinControls.UI.RadRating;
    if (rating != null)
    {
        averageRating += (double)rating.Value;
        numberOfChanges++;
        double result = averageRating / numberOfChanges;
        rating.Description = string.Format("Your rating: {0:F2}/{1}", result, rating.Maximum);
    }
}

5. Press F5 to run the application.

WinForms RadRating Getting Started Result

Telerik UI for WinForms Learning Resources

In this article