TimePicker 组件 — sgcHTML | eSeGeCe

TimePicker

TsgcHTMLComponent_TimePicker — 渲染带有可选最小和最大边界及秒级精度的原生 HTML5 时间输入框,适用于 Delphi、C++ Builder 和 .NET。

TsgcHTMLComponent_TimePicker

一个带标签的输入组件,生成 HTML5 time 类型的 Bootstrap form-control。设置边界,然后读取 HTML 属性(或调用静态 Build 辅助方法)。

组件类

TsgcHTMLComponent_TimePicker

渲染为

原生 HTML5 <input type="time">

语言

Delphi, C++ Builder, .NET

创建它、设置边界、渲染它

设置 FieldNameLabelTextMinTime/MaxTime 边界,然后读取 HTML — 或调用静态 Build 辅助方法一行完成。

uses
  sgcHTML_Component_TimePicker;

var
  oTime: TsgcHTMLComponent_TimePicker;
begin
  oTime := TsgcHTMLComponent_TimePicker.Create(nil);
  try
    oTime.FieldName := 'appointment_time';
    oTime.LabelText := 'Appointment time';
    oTime.MinTime := '08:00';
    oTime.MaxTime := '18:00';
    oTime.Required := True;

    WebModule.Response := oTime.HTML;   // <input type="time">
  finally
    oTime.Free;
  end;
end;

// Or the static one-liner (field name, label, value):
Result := TsgcHTMLComponent_TimePicker.Build('appointment_time', 'Appointment time');
// includes: sgcHTML_Component_TimePicker.hpp

TsgcHTMLComponent_TimePicker *oTime = new TsgcHTMLComponent_TimePicker(NULL);
try
{
  oTime->FieldName = "appointment_time";
  oTime->LabelText = "Appointment time";
  oTime->MinTime = "08:00";
  oTime->MaxTime = "18:00";
  oTime->Required = true;

  String html = oTime->HTML;   // <input type="time">
}
__finally
{
  delete oTime;
}

// Or the static one-liner:
String html = TsgcHTMLComponent_TimePicker::Build("appointment_time", "Appointment time");
using esegece.sgcWebSockets;

var time = new TsgcHTMLComponent_TimePicker();
time.FieldName = "appointment_time";
time.LabelText = "Appointment time";
time.MinTime = "08:00";
time.MaxTime = "18:00";
time.Required = true;

string html = time.HTML;   // <input type="time">

// Or the static one-liner:
string html2 = TsgcHTMLComponent_TimePicker.Build("appointment_time", "Appointment time");

关键属性与方法

您最常使用的成员。

字段

Value 预填充输入框;FieldName 设置其 nameLabelText 渲染一个 form-label

边界

MinTimeMaxTime 通过原生 min/max 属性限制可选范围。

精度

StepSeconds 直接设置 step 属性;ShowSeconds(默认 False)是一个快捷方式,当 StepSeconds 保持为 0 时请求一秒级精度。

验证与状态

RequiredDisabled 标记原生输入框。

尺寸

SizeTsgcHTMLSizehsExtraSmallhsExtraLarge,默认 hsMedium)对应 Bootstrap 的 form-control-sm/form-control-lg

静态辅助方法

Build(fieldName, labelText, value) 一行返回标记,无需管理实例。

继续探索

在线帮助此组件的完整 API 参考和使用指南。
所有 sgcHTML 组件浏览 80 多个组件的完整功能矩阵。
下载免费试用版30 天试用版附带 60.HTML 演示项目。
价格Single、Team 和 Site 授权,均含完整源代码。

准备好开始了吗?

下载免费试用版,为您的 Delphi、C++ Builder 或 .NET Web 应用添加日期和时间选择器。