Click here to Skip to main content
15,178,370 members
Articles / Desktop Programming / Windows Forms
Posted 2 Jun 2008


62 bookmarked

ShaperRater - A Rating Control

Rate me:
Please Sign up or sign in to vote.
4.88/5 (33 votes)
2 Jun 2008CPOL2 min read
A custom control to graphically select a ratings value.

Image 1


The ShaperRater is a simple bindable ratings control to graphically show a rating value. We've all used something similar before in rating music or movies.

Here is a list of its features:

  1. If you don't like stars, this control has other shapes to choose from.
  2. A label is available to display different text for each value.
  3. Separate border and fill colors for each state: empty, filled, or being hovered over.
  4. Value numbers (all or just selected value) can be displayed with the shape.


I was writing a DVD movie database program, and wanted to have a rating control like what I have seen elsewhere. I started out using little images, and although it did work, I wanted more versatility, so I started over and began drawing the shapes directly. This made design-time better, and made the control more dynamic.

Control Properties

Here is a list of the primary properties:

  • CurrentRating
  • This is the bindable ratings value.

  • MaxRating
  • How many shapes to draw.

  • Shape
  • Star, Circle, Square, Triangle, Heart, and Diamond.

  • RadiusOuter
  • Radius size for shape.

  • RadiusInner
  • The second radius of the Star shape.

  • ShapeGap
  • Set gap between each shape.

  • ShapeBorderEmptyColor, ShapeBorderFilledColor, ShapeBorderHoverColor
  • Color of the border for each state.

  • ShapeColorEmpty, ShapeColorFill, ShapeColorHover
  • Color to fill the shape for each state.

  • HighlightRateFill, HighlightRateHover
  • Changes the behavior of the fill and/or hover to highlight all the shapes or just the value shape.

  • ShapeNumberShow
  • Whether to show the number: None, All, or RateOnly.

  • ShapeNumberColor, ShapeNumberFont
  • Format the number shown.

  • ShapeNumberIndent
  • Tweak the position of the number.

  • LabelAlignment, LabelIndent, LabelShow
  • Label formatting options.

  • LabelText
  • Base text to display and 0 value text.

  • LabelTextItems
  • Text to display for each selected rating.

  • LabelFormatString
  • String.Format where {0} = rate being hovered over and {1} = the MaxRating.

  • LabelTypeHover, LabelTypeText
  • What type of text to display while hovering and after selection.

Using the Code

Once you get the ShaperRater designed the way you want, there isn't really any code. Just get the CurrentRating and use it the way you want:

Private Sub Rater1_CurrentRatingChanged(ByVal sender As System.Object, _
        ByVal e As System.EventArgs) Handles Rater1.CurrentRatingChanged

End Sub

Using the Control

  • Left click the control to select the CurrentRating.
  • Right click to reset the CurrentRating back to 0 during runtime.


  • Version 1.0 - March 2008.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer
United States United States
I first got hooked on programing with the TI994A. After it finally lost all support I reluctantly moved to the Apple IIe. Thank You BeagleBros for getting me through. I wrote programs for my Scuba buisness during this time. Currently I am a Database manager and software developer. I started with VBA and VB6 and now having fun with VB.NET/WPF/C#...

Comments and Discussions

Questionrating on Pin
Member 1459325916-May-21 2:58
MemberMember 1459325916-May-21 2:58 
GeneralMy Rating of 5 Pin
chrisf865727-Feb-15 23:17
Memberchrisf865727-Feb-15 23:17 
QuestionThanks for this. Great stuff Pin
Przemyslaw Koszka30-Jan-14 1:42
MemberPrzemyslaw Koszka30-Jan-14 1:42 
Questiontanx Pin
ali yeganeh17-Jan-13 23:59
Memberali yeganeh17-Jan-13 23:59 
GeneralGood stuff! [modified] Pin
Ton_B17-Sep-09 11:28
MemberTon_B17-Sep-09 11:28 
GeneralRe: Good stuff! Pin
SSDiver211218-Sep-09 9:00
MemberSSDiver211218-Sep-09 9:00 
GeneralRe: Good stuff! Pin
Ton_B19-Sep-09 0:31
MemberTon_B19-Sep-09 0:31 
GeneralReally good! Pin
z00z011-Jun-08 2:01
Memberz00z011-Jun-08 2:01 
GeneralNice one Pin
Ahmed IG2-Jun-08 8:28
MemberAhmed IG2-Jun-08 8:28 
GeneralRe: Nice one Pin
Sneeha30-Aug-08 19:25
MemberSneeha30-Aug-08 19:25 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.