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 — render a star (symbol) rating display or input with an optional hidden form field, in Delphi, C++ Builder and .NET.
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.
TsgcHTMLComponent_Rating
Symbol rating + hidden form input
Delphi, C++ Builder, .NET
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");
The members you reach for most often.
Value sets how many symbols are filled out of MaxValue (default 5); ShowValue appends a value/max caption.
ReadOnly (default True) renders the rating as a static display; set it False for an interactive input.
Color sets the filled-symbol color as a CSS string; ColorStyle (TsgcHTMLColor, e.g. hcWarning) picks a Bootstrap color when Color is empty.
FilledSymbol and EmptySymbol override the glyphs (default star ★); Size sets the font size.
Set InputName to emit a hidden <input> carrying the numeric value so the rating posts back with the form.
Build(value, maxValue, color) returns the markup in one line; HTML returns the symbol row plus the optional hidden input.