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

Customization

Hover, selected and selecting Background

RadRating introduces an easy way to customize the item’s BackColor when hovering, selecting, selected a value:


foreach (RatingStarVisualElement item in this.radRating1.Items)
{
    item.Fill.BackColor = Color.LightBlue;
    item.HoverElement.Fill.BackColor = Color.DeepSkyBlue;
    item.ValueElement.Fill.BackColor = Color.DodgerBlue;
    item.SelectedValueElement.Fill.BackColor = Color.Blue;
    item.Fill.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
    item.HoverElement.Fill.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
    item.ValueElement.Fill.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
    item.SelectedValueElement.Fill.GradientStyle = GradientStyles.Solid;
}

Figure 1: Default look

WinForms RadRating Default look

Figure 2: Customized look

WinForms RadRating Customized look

Custom Shape

By default RadRating supports three main element shapes: Stars, Diamonds and Hearts. If a different kind of shape is needed, RadRating allows you to create and use your own custom visual elements. The following example demonstrates creating a circle visual element:


for (int i = 0; i < 5; i++)
{
    CustomShapeElement myShape = new CustomShapeElement();
    myShape.Fill.BackColor = Color.LightBlue;
    myShape.HoverElement.Fill.BackColor = Color.DeepSkyBlue;
    myShape.ValueElement.Fill.BackColor = Color.DodgerBlue;
    myShape.SelectedValueElement.Fill.BackColor = Color.Blue;  

    myShape.Fill.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
    myShape.HoverElement.Fill.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
    myShape.ValueElement.Fill.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
    myShape.SelectedValueElement.Fill.GradientStyle = GradientStyles.Solid;
    this.radRating1.Items.Add(myShape);
}

public class CustomShapeElement : RatingVisualElement
{
    protected override ElementShape GetShape()
    {
        return new CustomShape();
    }

    protected override Type ThemeEffectiveType
    {
        get
        {
            return typeof(RatingVisualElement);
        }
    }
}

public class CustomShape : ElementShape
{
    public override GraphicsPath CreatePath(Rectangle bounds)
    {
        GraphicsPath path = new GraphicsPath();
        path.AddEllipse(bounds);

        return path;
    }
}

WinForms RadRating rating-customization 003