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 の入力と同じユニットに同梱されています。
TsgcHTMLComponent_CheckBox
Bootstrap 5 の form-check 入力
Delphi, C++ Builder, .NET
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 の入力が宣言されています。