AutoComplete

TsgcHTMLComponent_AutoComplete — 候補の HTML5 <datalist> を備えたテキスト入力を、JavaScript を一切必要とせずに Delphi、C++ Builder、.NET でレンダリングします。

TsgcHTMLComponent_AutoComplete

ネイティブな <datalist> に接続された Bootstrap の form-control を出力する入力コンポーネントです。候補の文字列を Items に追加したら、HTML プロパティを読み取ります。

コンポーネントクラス

TsgcHTMLComponent_AutoComplete

レンダリング結果

Bootstrap の入力 + HTML5 <datalist>

ファミリー

フォーム & 入力

言語

Delphi, C++ Builder, .NET

作成し、候補を追加し、レンダリングする

NameLabel_ を設定し、候補の文字列を Items に追加したら、HTML を読み取ります(または TsgcHTMLTemplate_Bootstrap のページに組み込みます)。

uses
  sgcHTML_Component_AutoComplete;

var
  oAuto: TsgcHTMLComponent_AutoComplete;
begin
  oAuto := TsgcHTMLComponent_AutoComplete.Create(nil);
  try
    oAuto.Name := 'country';
    oAuto.Label_ := 'Country';
    oAuto.Placeholder := 'Start typing...';
    oAuto.MinLength := 2;

    oAuto.Items.Add('Spain');
    oAuto.Items.Add('France');
    oAuto.Items.Add('Germany');

    WebModule.Response := oAuto.HTML;   // <input> + <datalist>
  finally
    oAuto.Free;
  end;
end;
// includes: sgcHTML_Component_AutoComplete.hpp

TsgcHTMLComponent_AutoComplete *oAuto = new TsgcHTMLComponent_AutoComplete(NULL);
try
{
  oAuto->Name = "country";
  oAuto->Label_ = "Country";
  oAuto->Placeholder = "Start typing...";
  oAuto->MinLength = 2;

  oAuto->Items->Add("Spain");
  oAuto->Items->Add("France");
  oAuto->Items->Add("Germany");

  String html = oAuto->HTML;   // <input> + <datalist>
}
__finally
{
  delete oAuto;
}
using esegece.sgcWebSockets;

var auto = new TsgcHTMLComponent_AutoComplete();
auto.Name = "country";
auto.Label_ = "Country";
auto.Placeholder = "Start typing...";
auto.MinLength = 2;

auto.Items.Add("Spain");
auto.Items.Add("France");
auto.Items.Add("Germany");

string html = auto.HTML;   // <input> + <datalist>

主なプロパティ & メソッド

最もよく使うメンバー。

フィールド

Name は入力の name を設定します。Label_ はその上に form-label をレンダリングし、Value はフィールドに初期値を設定します。

候補

ItemsTStringList)は、<datalist> 内の <option> エントリになる候補の文字列を保持します。

動作

Placeholder はヒントテキストを表示します。MinLength は候補が表示されるまでに入力する文字数を設定します(デフォルトは 1)。

識別子

AutoCompleteID は、入力とそれにリンクされた <datalist> が共有する要素の id を設定します。デフォルトは sgcAutoComplete です。

出力

HTML は、ラベル、form-control 入力、データを設定済みの <datalist> を含む mb-3 ラッパーを返します。

レイアウト

継承された SectionColumnWidthRowGroup が、TsgcHTMLPageBuilder のグリッド上にフィールドを配置します。

さらに詳しく

すべての sgcHTML コンポーネント60 種類以上のコンポーネントの完全な機能マトリックスを見る。
無料体験版をダウンロード30 日間の体験版には 60.HTML デモプロジェクトが付属します。
価格完全なソースコード付きの Single、Team、Site ライセンス。

始める準備はできましたか?

無料体験版をダウンロードして、Delphi、C++ Builder、.NET の Web アプリにオートコンプリート入力を追加しましょう。