设置DateTimePicker的默认值
目前我的 DateTimePickers 是空白的,我希望它们有一个默认设置,即
Today.AddYears(20); & Today.AddDays(5);
我现在所做的是 'DateTimePicker.Text = DateTime.Today.AddYears(-100).ToString();'正如您可能知道的那样,这不起作用,因此我才问这个问题。
一点信息:- 我需要它,以便如果它们没有更改并且按下按钮,它会使用默认日期。如果它们被更改,我显然需要使用更改后的日期。
建议。
XAML 添加:
<igEditors:XamDateTimeEditor Name="startDateTimePicker"
Grid.Row="1"
Grid.Column="1"
xmlns:igEditors="http://infragistics.com/Editors"
Height="18"
Width="100"
Format="yyyy-MM-dd"
VerticalAlignment="Top"
HorizontalAlignment="Center" />
Currently my DateTimePickers are blank, I would like them to have a default setting i.e
Today.AddYears(20); & Today.AddDays(5);
What I have done at the moment is 'DateTimePicker.Text = DateTime.Today.AddYears(-100).ToString();' As you can probably tell, this isn't working hence why I'm asking the question.
Bit of information :- I need it so that if they arent changed and the button is pressed it uses the default dates. If they are changed, I obviously need to use the changed dates.
Suggestions.
XAML ADDED:
<igEditors:XamDateTimeEditor Name="startDateTimePicker"
Grid.Row="1"
Grid.Column="1"
xmlns:igEditors="http://infragistics.com/Editors"
Height="18"
Width="100"
Format="yyyy-MM-dd"
VerticalAlignment="Top"
HorizontalAlignment="Center" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
设置
值
< /a> 属性应该可以解决问题:由于它的类型是
DateTime
,因此您不需要任何ToString
转换。Setting the
Value
property should do the trick:And since it's type is
DateTime
, you don't need anyToString
conversions.只需设置 DateTimePicker 控件的 value 属性即可。
Just set the value property of DateTimePicker Control.