Rating

TsgcHTMLComponent_Rating — render a star (symbol) rating display or input with an optional hidden form field, in Delphi, C++ Builder and .NET.

TsgcHTMLComponent_Rating

A rating component that emits a row of filled and empty symbols sized and colored to taste, plus an optional hidden input carrying the value. Set the value and max, then read the HTML property.

Component class

TsgcHTMLComponent_Rating

Renders

Symbol rating + hidden form input

Languages

Delphi, C++ Builder, .NET

Create it, set the value, render it

Set Value and MaxValue, choose a color and symbols, then read HTML — or call the static Build helper for a one-liner.

uses
  sgcHTML_Component_Rating;

var
  oRating: TsgcHTMLComponent_Rating;
begin
  oRating := TsgcHTMLComponent_Rating.Create(nil);
  try
    oRating.Value := 4;
    oRating.MaxValue := 5;
    oRating.Color := '#ffc107';
    oRating.ShowValue := True;
    oRating.InputName := 'score';
    oRating.ReadOnly := False;

    WebModule.Response := oRating.HTML;   // stars + hidden input
  finally
    oRating.Free;
  end;
end;

// Or the static one-liner (value, maxValue, color):
Result := TsgcHTMLComponent_Rating.Build(4, 5, '#ffc107');
// includes: sgcHTML_Component_Rating.hpp

TsgcHTMLComponent_Rating *oRating = new TsgcHTMLComponent_Rating(NULL);
try
{
  oRating->Value = 4;
  oRating->MaxValue = 5;
  oRating->Color = "#ffc107";
  oRating->ShowValue = true;
  oRating->InputName = "score";
  oRating->ReadOnly = false;

  String html = oRating->HTML;   // stars + hidden input
}
__finally
{
  delete oRating;
}

// Or the static one-liner:
String html = TsgcHTMLComponent_Rating::Build(4, 5, "#ffc107");
using esegece.sgcWebSockets;

var rating = new TsgcHTMLComponent_Rating();
rating.Value = 4;
rating.MaxValue = 5;
rating.Color = "#ffc107";
rating.ShowValue = true;
rating.InputName = "score";
rating.ReadOnly = false;

string html = rating.HTML;   // stars + hidden input

// Or the static one-liner:
string html2 = TsgcHTMLComponent_Rating.Build(4, 5, "#ffc107");

Key properties & methods

The members you reach for most often.

Value

Value sets how many symbols are filled out of MaxValue (default 5); ShowValue appends a value/max caption.

Mode

ReadOnly (default True) renders the rating as a static display; set it False for an interactive input.

Color

Color sets the filled-symbol color as a CSS string; ColorStyle (TsgcHTMLColor, e.g. hcWarning) picks a Bootstrap color when Color is empty.

Symbols

FilledSymbol and EmptySymbol override the glyphs (default star ★); Size sets the font size.

Form binding

Set InputName to emit a hidden <input> carrying the numeric value so the rating posts back with the form.

Static helper & output

Build(value, maxValue, color) returns the markup in one line; HTML returns the symbol row plus the optional hidden input.

Keep exploring

All sgcHTML ComponentsBrowse the full feature matrix of 60+ components.
Download Free TrialThe 30-day trial ships the 60.HTML demo projects.
PricingSingle, Team and Site licenses with full source code.

Ready to Get Started?

Download the free trial and add star ratings to your Delphi, C++ Builder or .NET web app.