ListGroup

TsgcHTMLComponent_ListGroup — render a list group of links or items with badges and content, from your own items or directly from a dataset, in Delphi, C++ Builder and .NET.

TsgcHTMLComponent_ListGroup

A list component that emits a Bootstrap 5 list-group. Add items (with optional badges and content), set the flush / numbered / horizontal flags, then read the HTML property.

Component class

TsgcHTMLComponent_ListGroup

Renders

Bootstrap 5 list-group markup

Languages

Delphi, C++ Builder, .NET

Create it, add items, render it

Call AddItem(text, href, badge, badgeStyle) for each row (or push into Items directly), set the layout flags, then read HTML (or drop it into a TsgcHTMLTemplate_Bootstrap page).

uses
  sgcHTML_Enums, sgcHTML_Component_ListGroup;

var
  oList: TsgcHTMLComponent_ListGroup;
begin
  oList := TsgcHTMLComponent_ListGroup.Create(nil);
  try
    oList.Flush := True;

    oList.AddItem('Inbox', '/inbox', '14', bgPrimary);
    oList.AddItem('Drafts', '/drafts', '2', bgSecondary);
    oList.AddItem('Spam', '/spam', '99+', bgDanger);

    WebModule.Response := oList.HTML;   // Bootstrap list-group
  finally
    oList.Free;
  end;
end;

// Or fill the list straight from a dataset:
oList.LoadFromDataSet(qryFolders, 'Name', 'Url', 'Unread');
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_ListGroup.hpp

TsgcHTMLComponent_ListGroup *oList = new TsgcHTMLComponent_ListGroup(NULL);
try
{
  oList->Flush = true;

  oList->AddItem("Inbox", "/inbox", "14", bgPrimary);
  oList->AddItem("Drafts", "/drafts", "2", bgSecondary);
  oList->AddItem("Spam", "/spam", "99+", bgDanger);

  String html = oList->HTML;   // Bootstrap list-group
}
__finally
{
  delete oList;
}
using esegece.sgcWebSockets;

var list = new TsgcHTMLComponent_ListGroup();
list.Flush = true;

list.AddItem("Inbox", "/inbox", "14", TsgcHTMLBadgeStyle.bgPrimary);
list.AddItem("Drafts", "/drafts", "2", TsgcHTMLBadgeStyle.bgSecondary);
list.AddItem("Spam", "/spam", "99+", TsgcHTMLBadgeStyle.bgDanger);

string html = list.HTML;   // Bootstrap list-group

// Or fill the list straight from a dataset:
list.LoadFromDataSet(qryFolders, "Name", "Url", "Unread");

Key properties & methods

The members you reach for most often.

Items

Items is the TsgcHTMLListGroupItems collection; each TsgcHTMLListGroupItem carries Text, Href, Badge, BadgeStyle, Active, Disabled and Content.

AddItem

AddItem(aText, aHref, aBadge, aBadgeStyle) appends a row in one call; a non-empty Href renders the item as a clickable list-group-item-action link.

Dataset binding

LoadFromDataSet(aDataSet, aTextField, aHrefField, aBadgeField) fills the list from a query, one item per row.

Badges & content

Set an item's Badge with a BadgeStyle (a TsgcHTMLBadgeStyle such as bgPrimary) for a pill counter, and Content for a secondary description line.

Layout

Flush removes the outer borders, Numbered renders an ordered list-group-numbered, and Horizontal lays items out in a row.

Output

HTML returns the list-group markup and ListGroupID sets its element id — serve it, or assign it to a page template's BodyContent.

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 start building web UIs in Delphi, C++ Builder and .NET.