CheckBox

TsgcHTMLComponent_CheckBox — un campo checkbox (o interruttore) con etichetta e binding ai dataset che renderizza markup form-check Bootstrap 5, in Delphi, C++ Builder e .NET.

TsgcHTMLComponent_CheckBox

Un campo booleano autonomo che emette un form-check Bootstrap — attiva Switch per renderizzarlo come interruttore. Imposta il nome, l’etichetta e lo stato selezionato, quindi leggi la proprietà HTML. È distribuito nella stessa unit dei campi affini Edit, Memo e RadioGroup.

Classe del componente

TsgcHTMLComponent_CheckBox

Renderizza

Bootstrap 5 form-check input

Famiglia

Moduli e Campi

Linguaggi

Delphi, C++ Builder, .NET

Crealo, configuralo, renderizzalo

Imposta Name, Label_ e Checked (e facoltativamente Switch), quindi leggi HTML (oppure inseriscilo in una pagina TsgcHTMLTemplate_Bootstrap).

uses
  sgcHTML_Component_Edit;

var
  oCheck: TsgcHTMLComponent_CheckBox;
begin
  oCheck := TsgcHTMLComponent_CheckBox.Create(nil);
  try
    oCheck.Name := 'newsletter';
    oCheck.Label_ := 'Subscribe to the newsletter';
    oCheck.Checked := True;
    oCheck.Switch := True;   // render as a toggle switch

    WebModule.Response := oCheck.HTML;   // Bootstrap form-check
  finally
    oCheck.Free;
  end;
end;

// Or bind it to a boolean dataset field:
oCheck.DataField := 'Active';
oCheck.DataSource := dsCustomer;
// includes: sgcHTML_Component_Edit.hpp

TsgcHTMLComponent_CheckBox *oCheck = new TsgcHTMLComponent_CheckBox(NULL);
try
{
  oCheck->Name = "newsletter";
  oCheck->Label_ = "Subscribe to the newsletter";
  oCheck->Checked = true;
  oCheck->Switch = true;   // render as a toggle switch

  String html = oCheck->HTML;   // Bootstrap form-check
}
__finally
{
  delete oCheck;
}
using esegece.sgcWebSockets;

var check = new TsgcHTMLComponent_CheckBox();
check.Name = "newsletter";
check.Label_ = "Subscribe to the newsletter";
check.Checked = true;
check.Switch = true;   // render as a toggle switch

string html = check.HTML;   // Bootstrap form-check

Proprietà e metodi principali

I membri che utilizzerai più spesso.

Identità

Name imposta il nome del campo, Label_ la didascalia visibile e CheckBoxID l’id dell’elemento (il valore predefinito è chk_<Name>).

Stato

Checked imposta il valore iniziale e Disabled disattiva il controllo.

Switch

Switch sostituisce la casella con un interruttore Bootstrap form-switch mantenendo la stessa semantica della checkbox.

Binding ai dataset

DataField insieme a un DataSource assegnato imposta Checked dal campo booleano del record corrente.

Output e campi affini

HTML restituisce il wrapper form-check con il suo input e l’etichetta. La stessa unit dichiara i campi affini TsgcHTMLComponent_Edit, TsgcHTMLComponent_Memo e TsgcHTMLComponent_RadioGroup.

Continua a esplorare

Tutti i componenti sgcHTMLEsplora la matrice completa delle funzionalità di oltre 60 componenti.
Scarica la Prova GratuitaLa prova di 30 giorni include i progetti demo 60.HTML.
PrezziLicenze Single, Team e Site con codice sorgente completo.

Pronto a Iniziare?

Scarica la versione di prova gratuita e inizia a creare interfacce web in Delphi, C++ Builder e .NET.