Dropdown
TsgcHTMLComponent_Dropdown — render a Bootstrap dropdown button with a menu of links, headers and dividers, in Delphi, C++ Builder and .NET.
TsgcHTMLComponent_Dropdown — render a Bootstrap dropdown button with a menu of links, headers and dividers, in Delphi, C++ Builder and .NET.
A dropdown component that emits a Bootstrap 5 toggle button plus its <ul class="dropdown-menu">. Add menu items, set the button style, then read the HTML property.
TsgcHTMLComponent_Dropdown
Bootstrap 5 dropdown button + menu
Delphi, C++ Builder, .NET
Set ButtonText and ButtonStyleEnum, add link / header / divider items, then read HTML (or drop it into a TsgcHTMLTemplate_Bootstrap page).
uses
sgcHTML_Enums, sgcHTML_Component_Dropdown;
var
oDropdown: TsgcHTMLComponent_Dropdown;
oItem: TsgcHTMLDropdownItem;
begin
oDropdown := TsgcHTMLComponent_Dropdown.Create(nil);
try
oDropdown.ButtonText := 'Account';
oDropdown.ButtonStyleEnum := bsPrimary;
oItem := oDropdown.Items.Add;
oItem.Text := 'Settings';
oItem.Header := True;
oItem := oDropdown.Items.Add;
oItem.Text := 'Profile';
oItem.Href := '/profile';
oItem := oDropdown.Items.Add;
oItem.Divider := True;
oItem := oDropdown.Items.Add;
oItem.Text := 'Sign out';
oItem.Href := '/logout';
WebModule.Response := oDropdown.HTML; // Bootstrap dropdown
finally
oDropdown.Free;
end;
end;
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_Dropdown.hpp
TsgcHTMLComponent_Dropdown *oDropdown = new TsgcHTMLComponent_Dropdown(NULL);
try
{
oDropdown->ButtonText = "Account";
oDropdown->ButtonStyleEnum = bsPrimary;
TsgcHTMLDropdownItem *oItem = oDropdown->Items->Add();
oItem->Text = "Settings";
oItem->Header = true;
oItem = oDropdown->Items->Add();
oItem->Text = "Profile";
oItem->Href = "/profile";
oItem = oDropdown->Items->Add();
oItem->Divider = true;
oItem = oDropdown->Items->Add();
oItem->Text = "Sign out";
oItem->Href = "/logout";
String html = oDropdown->HTML; // Bootstrap dropdown
}
__finally
{
delete oDropdown;
}
using esegece.sgcWebSockets;
var dropdown = new TsgcHTMLComponent_Dropdown();
dropdown.ButtonText = "Account";
dropdown.ButtonStyleEnum = TsgcHTMLButtonStyle.bsPrimary;
var item = dropdown.Items.Add();
item.Text = "Settings";
item.Header = true;
item = dropdown.Items.Add();
item.Text = "Profile";
item.Href = "/profile";
item = dropdown.Items.Add();
item.Divider = true;
item = dropdown.Items.Add();
item.Text = "Sign out";
item.Href = "/logout";
string html = dropdown.HTML; // Bootstrap dropdown
The members you reach for most often.
Items is the TsgcHTMLDropdownItems collection; Items.Add returns a TsgcHTMLDropdownItem with Text, Href, Disabled and the Header / Divider flags.
Set Header for a section label, Divider for a separator line, or leave both off for a plain link entry; Disabled greys an entry out.
ButtonText is the toggle caption; ButtonStyleEnum (a TsgcHTMLButtonStyle such as bsPrimary) selects the variant, and ButtonClass overrides it with raw classes.
Split renders the toggle as a separate caret button alongside the main action button.
HTML returns the dropdown wrapper, toggle button and menu and DropdownID sets its element id — serve it, or assign it to a page template's BodyContent.