Results 1 to 36 of 36

Thread: Star Rating Control

Threaded View

  1. #1

    Thread Starter
    Hyperactive Member stepdragon's Avatar
    Join Date
    Aug 2011
    Location
    Cincinnati
    Posts
    288

    Star Rating Control

    *UPDATED* 4/15/2012 - Overrides OnPaint instead of handling paint, so that graphics show up at design time. Thank you minitech for the suggestion!

    I found the need for a simple, yet good looking Star Rating control. I haven't made a user control since I was programming in VB5, so this was quite a challenge for me.

    If you use my control, please reply or send me a pm to let me know! I love knowing when I help someone!
    Its here for you to use, no need to contact me if you need it. I just like knowing (it makes me proud)

    The control uses GDI+ to draw the stars from images.
    Moving the mouse highlights what stars can be chosen.


    The Control Contains 7 Custom Properties:
    1. StarCount as Integer - (Number of stars / Highest possible rating)
    2. Value as Integer - (Number of Stars Lit)
    3. StarHeight as Integer
    4. StarWidth as Integer
    5. StarGold as Image - (optional Image to override the default Star Image)
    6. StarGray as Image - (optional Image to override the default Star Image)
    7. DisplayOnly as Boolean - (when True it disables the control from updating on MouseOver or Click)

    (StarHeight and StarWidth adjust the visible size of the Stars. That way the control can be used when multiple sizes are needed)
    (Both StarGold and StarGray must be valid or neither will be replaced. You can set them to (none) to return to the default stars)

    It also Contains one Custom Event:
    ValueChanged(Value, UserChanged as Boolean) - Raised whenever the Value is changed
    UserChanged was added so you will know if the value was changed by code or by clicking on it.
    That will allow you to change the appearance of the control without messing up numbers in your program.

    To use the control, open the project (made in VS2010 express) and build it. Then open your project, right click on the toolbox, and choose "Choose Items...". Under ".Net Framework Components" Navigate to the Bin Folder of the Control Project and add it. You can then use the control like any other.



    If you have any problems loading, building, or testing this control, please let me know. Its my first in .net and I want to get it working.

    UPDATE: I added a DisplayOnly Property so that you could disable user input
    It works well if you just want to show a rating, rather than set one.

    I also commented the entire project.
    Attached Files Attached Files
    Last edited by stepdragon; Apr 15th, 2012 at 12:39 AM.

    If you're wrong, you'll learn. If I'm wrong, I'll learn. Try something new and go from there. That's how we improve.

    CodeBank: VB.Net - Simple Proper Image Scaling in Correct Aspect Ratio - Star Rating Control
    Useful Links: HOW TO USE CODE TAGS

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width