Accordion
TsgcHTMLComponent_Accordion — render a vertically collapsing accordion of stacked, expandable panels, in Delphi, C++ Builder and .NET.
TsgcHTMLComponent_Accordion — render a vertically collapsing accordion of stacked, expandable panels, in Delphi, C++ Builder and .NET.
A stack of collapsible panels built on the Bootstrap accordion. Add items with a title and content, mark which start open, then read the HTML property.
TsgcHTMLComponent_Accordion
Bootstrap 5 accordion markup
Delphi, C++ Builder, .NET
Add each panel through Items.Add, set its Title, Content and Expanded flag, then read HTML.
uses
sgcHTML_Component_Accordion;
var
oAcc: TsgcHTMLComponent_Accordion;
begin
oAcc := TsgcHTMLComponent_Accordion.Create(nil);
try
oAcc.AccordionID := 'faq';
oAcc.Flush := False;
oAcc.AlwaysOpen := False;
with oAcc.Items.Add do
begin
Title := 'What is sgcHTML?';
Content := 'A server-side HTML component library.';
Expanded := True;
end;
with oAcc.Items.Add do
begin
Title := 'Which languages?';
Content := 'Delphi, C++ Builder and .NET.';
end;
WebModule.Response := oAcc.HTML; // Bootstrap accordion
finally
oAcc.Free;
end;
end;
// includes: sgcHTML_Component_Accordion.hpp
TsgcHTMLComponent_Accordion *oAcc = new TsgcHTMLComponent_Accordion(NULL);
try
{
oAcc->AccordionID = "faq";
oAcc->Flush = false;
oAcc->AlwaysOpen = false;
TsgcHTMLAccordionItem *oItem = oAcc->Items->Add();
oItem->Title = "What is sgcHTML?";
oItem->Content = "A server-side HTML component library.";
oItem->Expanded = true;
oItem = oAcc->Items->Add();
oItem->Title = "Which languages?";
oItem->Content = "Delphi, C++ Builder and .NET.";
String html = oAcc->HTML; // Bootstrap accordion
}
__finally
{
delete oAcc;
}
using esegece.sgcWebSockets;
var acc = new TsgcHTMLComponent_Accordion();
acc.AccordionID = "faq";
acc.Flush = false;
acc.AlwaysOpen = false;
var item = acc.Items.Add();
item.Title = "What is sgcHTML?";
item.Content = "A server-side HTML component library.";
item.Expanded = true;
item = acc.Items.Add();
item.Title = "Which languages?";
item.Content = "Delphi, C++ Builder and .NET.";
string html = acc.HTML; // Bootstrap accordion
The members you reach for most often.
Items (TsgcHTMLAccordionItems) holds the panels; call Items.Add to append one and configure it.
Each item exposes Title for the header button, Content for the panel body and Expanded to start it open.
AlwaysOpen lets several panels stay open at once; with it off, opening one panel collapses the others.
Flush removes the outer borders and rounded corners for an edge-to-edge accordion.
AccordionID sets the container id used to wire the collapse parent for the panels.
HTML returns the full accordion markup — serve it, or assign it to a page template's body content.