ProgressBar Component — sgcHTML | eSeGeCe

ProgressBar

TsgcHTMLComponent_ProgressBar — a Bootstrap progress bar, striped and animated, with an optional label, or a stacked multi-segment bar, in Delphi, C++ Builder and .NET.

TsgcHTMLComponent_ProgressBar

Set Value and Max for a single bar, or add entries to Bars for a stacked multi-segment bar, then read the HTML property.

Component class

TsgcHTMLComponent_ProgressBar

Renders

Bootstrap 5 .progress bar (single or stacked)

Languages

Delphi, C++ Builder, .NET

Set the value, style it, render it

Set Value, Max and ColorStyle, turn on Striped / Animated / ShowLabel as needed, then read HTML.

uses
  sgcHTML_Enums, sgcHTML_Component_ProgressBar;

var
  oBar: TsgcHTMLComponent_ProgressBar;
begin
  oBar := TsgcHTMLComponent_ProgressBar.Create(nil);
  try
    oBar.ProgressBarID := 'upload';
    oBar.Value := 72;
    oBar.Max := 100;
    oBar.ColorStyle := hcSuccess;
    oBar.Striped := True;
    oBar.Animated := True;
    oBar.ShowLabel := True;
    oBar.LabelFormat := '%d%% complete';

    WebModule.Response := oBar.HTML;   // Bootstrap progress bar
  finally
    oBar.Free;
  end;
end;

// Or a stacked, multi-segment bar:
with oBar.Bars.Add do
begin
  Value := 40;
  ColorStyle := hcPrimary;
  Label_ := 'Done';
end;
with oBar.Bars.Add do
begin
  Value := 20;
  ColorStyle := hcWarning;
  Label_ := 'In progress';
end;
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_ProgressBar.hpp

TsgcHTMLComponent_ProgressBar *oBar = new TsgcHTMLComponent_ProgressBar(NULL);
try
{
  oBar->ProgressBarID = "upload";
  oBar->Value = 72;
  oBar->Max = 100;
  oBar->ColorStyle = hcSuccess;
  oBar->Striped = true;
  oBar->Animated = true;
  oBar->ShowLabel = true;
  oBar->LabelFormat = "%d%% complete";

  String html = oBar->HTML;   // Bootstrap progress bar

  // Or a stacked, multi-segment bar:
  TsgcHTMLProgressBarItem *oSeg1 = oBar->Bars->Add();
  oSeg1->Value = 40;
  oSeg1->ColorStyle = hcPrimary;
  oSeg1->Label_ = "Done";

  TsgcHTMLProgressBarItem *oSeg2 = oBar->Bars->Add();
  oSeg2->Value = 20;
  oSeg2->ColorStyle = hcWarning;
  oSeg2->Label_ = "In progress";
}
__finally
{
  delete oBar;
}
using esegece.sgcWebSockets;

var bar = new TsgcHTMLComponent_ProgressBar();
bar.ProgressBarID = "upload";
bar.Value = 72;
bar.Max = 100;
bar.ColorStyle = TsgcHTMLColor.hcSuccess;
bar.Striped = true;
bar.Animated = true;
bar.ShowLabel = true;
bar.LabelFormat = "%d%% complete";

string html = bar.HTML;   // Bootstrap progress bar

// Or a stacked, multi-segment bar:
var seg1 = bar.Bars.Add();
seg1.Value = 40;
seg1.ColorStyle = TsgcHTMLColor.hcPrimary;
seg1.Label_ = "Done";

var seg2 = bar.Bars.Add();
seg2.Value = 20;
seg2.ColorStyle = TsgcHTMLColor.hcWarning;
seg2.Label_ = "In progress";

Key properties & methods

The members you reach for most often.

Single bar

Value and Max (default 100) set the fill width as a percentage; ColorStyle picks the Bootstrap colour, or set a raw CSS colour with Color.

Label

ShowLabel renders the percentage text inside the bar; LabelFormat (default %d%%) controls how it's formatted.

Striped & animated

Striped adds diagonal stripes; Animated implies striped and animates them across the bar.

Stacked segments

Bars.Add appends a TsgcHTMLProgressBarItem (Value, ColorStyle / Color, Label_); once Bars has entries they replace the single Value bar.

Sizing & identity

Height sets a custom CSS bar height; ProgressBarID (or ElementID) names the outer <div class="progress"> for fragment pushes.

Output

HTML returns the progress wrapper plus its bar segment(s), ready to embed or push over WebSockets as the value changes.

Keep exploring

Online HelpFull API reference and usage guide for this component.
All sgcHTML ComponentsBrowse the full feature matrix of 80+ 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 progress bars to your Delphi, C++ Builder or .NET web app.