feat: 新增时间输入和Alt按钮快捷键
This commit is contained in:
@@ -4244,6 +4244,29 @@ namespace Lskj.Control
|
||||
RepositoryItemTimeEdit timeEdit = new RepositoryItemTimeEdit();
|
||||
timeEdit.DisplayFormat.FormatString = timeEdit.EditFormat.FormatString = timeEdit.Mask.EditMask = DateFormat.Format(fieldType);
|
||||
timeEdit.DisplayFormat.FormatType = timeEdit.EditFormat.FormatType = DevExpress.Utils.FormatType.Custom;
|
||||
timeEdit.ParseEditValue += delegate(object sender, ConvertEditValueEventArgs e)
|
||||
{
|
||||
// SQL Server 的 time 字段在 DataTable 中是 TimeSpan,TimeEdit 输入后返回 DateTime。
|
||||
// 只转换 TimeSpan 绑定列,不改变原有 DateTime 类型列的行为。
|
||||
if (gridColumn.ColumnType != typeof(TimeSpan) || e.Value == null || e.Value == DBNull.Value)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.Value is DateTime)
|
||||
{
|
||||
e.Value = ((DateTime)e.Value).TimeOfDay;
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
TimeSpan timeValue;
|
||||
if (!(e.Value is TimeSpan) && TimeSpan.TryParse(e.Value.ToString(), out timeValue))
|
||||
{
|
||||
e.Value = timeValue;
|
||||
e.Handled = true;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user