CheckBox
TsgcHTMLComponent_CheckBox — 一个带标签和数据集绑定的复选框(或拨动开关)输入,渲染 Bootstrap 5 form-check 标记,适用于 Delphi、C++ Builder 和 .NET。
TsgcHTMLComponent_CheckBox — 一个带标签和数据集绑定的复选框(或拨动开关)输入,渲染 Bootstrap 5 form-check 标记,适用于 Delphi、C++ Builder 和 .NET。
一个独立的布尔输入,发出 Bootstrap form-check — 切换 Switch 可将其渲染为拨动开关。设置名称、标签和选中状态,然后读取 HTML 属性。它与同级的 Edit、Memo 和 RadioGroup 输入位于同一单元中。
设置 Name、Label_ 和 Checked(可选地设置 Switch),然后读取 HTML(或将其放入 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
您最常使用的成员。
Name 设置字段名称,Label_ 设置可见标题,CheckBoxID 设置元素 id(默认为 chk_<Name>)。
Checked 设置初始值,Disabled 将控件置灰。
Switch 将复选框替换为 Bootstrap form-switch 拨动开关,同时保持相同的复选框语义。
DataField 加上已赋值的 DataSource 会从当前记录的布尔字段设置 Checked。
HTML 返回带有输入框和标签的 form-check 包装器。同一单元声明了同级的 TsgcHTMLComponent_Edit、TsgcHTMLComponent_Memo 和 TsgcHTMLComponent_RadioGroup 输入。