Select
TsgcHTMLComponent_Select — un desplegable select de Bootstrap 5 con optgroups, selección múltiple, tamaño y vinculación a datasets, en Delphi, C++ Builder y .NET.
TsgcHTMLComponent_Select — un desplegable select de Bootstrap 5 con optgroups, selección múltiple, tamaño y vinculación a datasets, en Delphi, C++ Builder y .NET.
Un desplegable que genera un form-select de Bootstrap con etiqueta. Añade opciones (o vincula un dataset), opcionalmente agrúpalas y permite la selección múltiple y luego lee la propiedad HTML.
TsgcHTMLComponent_Select
form-select de Bootstrap 5
Delphi, C++ Builder, .NET
Configura Name, Label_ y un Placeholder, añade opciones con AddOption (o AddOptionGroup) y luego lee HTML (o colócalo en una página TsgcHTMLTemplate_Bootstrap).
uses
sgcHTML_Enums, sgcHTML_Component_Select;
var
oSelect: TsgcHTMLComponent_Select;
begin
oSelect := TsgcHTMLComponent_Select.Create(nil);
try
oSelect.Name := 'country';
oSelect.Label_ := 'Country';
oSelect.Placeholder := 'Select a country';
oSelect.Size := ssLarge;
oSelect.AddOption('es', 'Spain', True);
oSelect.AddOption('fr', 'France');
oSelect.AddOptionGroup('Americas', 'us', 'United States');
WebModule.Response := oSelect.HTML; // Bootstrap form-select
finally
oSelect.Free;
end;
end;
// Or fill it straight from a dataset:
oSelect.LoadFromDataSet(qryCountries, 'Code', 'Name', 'Region');
// includes: sgcHTML_Enums.hpp, sgcHTML_Component_Select.hpp
TsgcHTMLComponent_Select *oSelect = new TsgcHTMLComponent_Select(NULL);
try
{
oSelect->Name = "country";
oSelect->Label_ = "Country";
oSelect->Placeholder = "Select a country";
oSelect->Size = ssLarge;
oSelect->AddOption("es", "Spain", true);
oSelect->AddOption("fr", "France");
oSelect->AddOptionGroup("Americas", "us", "United States");
String html = oSelect->HTML; // Bootstrap form-select
}
__finally
{
delete oSelect;
}
using esegece.sgcWebSockets;
var select = new TsgcHTMLComponent_Select();
select.Name = "country";
select.Label_ = "Country";
select.Placeholder = "Select a country";
select.Size = TsgcHTMLSelectSize.ssLarge;
select.AddOption("es", "Spain", true);
select.AddOption("fr", "France");
select.AddOptionGroup("Americas", "us", "United States");
string html = select.HTML; // Bootstrap form-select
Los miembros que más utilizarás.
Options es una colección de TsgcHTMLSelectOption (cada una con Value, Text, Selected, Disabled y Group); los métodos de conveniencia AddOption(value, text, selected) y AddOptionGroup(group, value, text) la rellenan.
Name establece el nombre del campo, Label_ el rótulo, Placeholder una opción inicial deshabilitada y SelectID el id del elemento (por defecto sel_<Name>).
Multiple la convierte en una lista de selección múltiple y VisibleItems establece cuántas filas se muestran a la vez (el atributo size).
Size es un TsgcHTMLSelectSize — ssDefault, ssSmall o ssLarge.
LoadFromDataSet(aDataSet, aValueField, aTextField, aGroupField) rellena las opciones a partir de una consulta, construyendo <optgroup>s cuando se proporciona un campo de grupo; asigna DataSource para refresco en vivo.
Required y Disabled marcan el control; HTML devuelve el <select> con etiqueta con todas las opciones y optgroups.
| Todos los componentes de sgcHTMLExplora la matriz de características completa de más de 60 componentes. | Abrir | |
| Descargar prueba gratuitaLa prueba de 30 días incluye los proyectos de demostración 60.HTML. | Abrir | |
| PreciosLicencias Single, Team y Site con todo el código fuente. | Abrir |