DataGridDateTimeColumn EditMode="Time" ShortTime类型
现在以5分的增长 如何控制1分的增长 回复 1楼q406157290的帖子
dataGrid.BeganEdit += (sender, e) =>
{
((C1.WPF.DateTimeEditors.C1DateTimePicker)(e.EditingElement)).TimeIncrement = new TimeSpan(0, 1, 0);
};
可以在编辑单元格时将其中的C1DateTimePicker控件的TimeIncrement 属性设置成1分钟; 回复 2楼KNight的帖子
<c1:C1DateTimePicker DateTime ="{Binding PageModel.MeasTime, Mode=TwoWay}" TimeIncrement="00:01:00" />
C1DateTimePicker 有这样的属性TimeIncrement
DataGridDateTimeColumn 没有类似的属性吗
我实现不想在后台写 回复 3楼q406157290的帖子
没有这个属性。
但在wpf平台下,你可以自定义模板,你可以给Column制定一个DateTimePicker类型的DataTemplate,并设置TimeIncrement属性。如何给C1DataGrid的列设置模板,之前的帖子里都有关详细的方法。 回复 4楼Alice的帖子
也就是说 C1DateTimePicker 设置成时间类型的话就只能按照5分钟的增长 ,而且还不能通过某个属性修改增长幅度这是不是有点......... 回复 5楼q406157290的帖子
很抱歉没有理解你的意思。
2楼和4楼分别给出了两种解决方法,可是你说不能实现,我不太理解。 回复 5楼q406157290的帖子
public override FrameworkElement GetCellEditingContent(DataGridRow row)
{
Control control;
if (this.EditMode == DataGridDateTimeColumnEditMode.Custom)
{
control = new C1TextBoxBase();
if (base.Binding != null)
{
Binding binding = base.CopyBinding(base.Binding, null);
control.SetBinding(C1TextBoxBase.C1TextProperty, binding);
}
}
else
{
C1DateTimePicker c1DateTimePicker = new C1DateTimePicker();
switch (this.EditMode)
{
case DataGridDateTimeColumnEditMode.Date:
c1DateTimePicker.EditMode = C1DateTimePickerEditMode.Date;
break;
case DataGridDateTimeColumnEditMode.Time:
c1DateTimePicker.EditMode = C1DateTimePickerEditMode.Time;
break;
}
c1DateTimePicker.DateFormat = this.DateFormat;
c1DateTimePicker.TimeFormat = this.TimeFormat;
c1DateTimePicker.CustomDateFormat = this.CustomDateFormat;
c1DateTimePicker.CustomTimeFormat = this.CustomTimeFormat;
c1DateTimePicker.HorizontalAlignment = base.HorizontalAlignment;
c1DateTimePicker.AllowNull = base.AllowNull;
c1DateTimePicker.MaxDate = this.MaxDate;
c1DateTimePicker.MinDate = this.MinDate;
if (this._firstDayOfWeekSet)
{
c1DateTimePicker.FirstDayOfWeek = this.FirstDayOfWeek;
}
c1DateTimePicker.Padding = new Thickness(0.0);
c1DateTimePicker.CornerRadius = new CornerRadius(0.0);
if (base.Binding != null)
{
Binding binding2 = base.CopyBinding(base.Binding, null);
c1DateTimePicker.SetBinding(C1DateTimePicker.DateTimeProperty, binding2);
}
c1DateTimePicker.AddHandler(UIElement.KeyDownEvent,
new KeyEventHandler(this.picker_KeyDown), true);
control = c1DateTimePicker;
}
control.VerticalContentAlignment = base.VerticalAlignment;
if (base.CellEditingContentStyle != null)
{
control.Style = base.CellEditingContentStyle;
}
return control;
}
DataGridDateTimeColumn实际上用的也是c1DateTimePicker控件的,只是该控件默认增减幅度为5分钟,
C1DateTimePicker.TimeIncrementProperty = DependencyProperty.Register("TimeIncrement", typeof(TimeSpan), typeof(C1DateTimePicker), new PropertyMetadata(TimeSpan.FromMinutes(5.0)));
而且在DataGridDateTimeColumn中C1DateTimePicker也是New出来的,且并未开放该控件属性或者该控件的增减幅度(TimeIncrement)属性,所以无法在XAML中配置;
程序员自当灵活使用控件,毕竟不会存在完美的控件,完美的代码,完美的程序员; 回复 6楼Alice的帖子
辛苦您了但是我没说2楼和4楼给出的解决方法不能实现,只是不想用那种方式 回复 7楼KNight的帖子
:i0tw:谢谢您 辛苦您了 回复 8楼q406157290的帖子
很抱歉没有理解您的意思。
7楼@KNight给出了详细的方案。
此问题关闭。
页:
[1]