我正在尝试将当前时间设置为 DateTimePicker(带有格式时间)
this.myDateTimePicker.Value = DateTime.Now;
但是在执行我的代码时出现异常
Object reference not set to an instance of an object
我做错了什么?
谢谢。
最佳答案
您需要在 InitializeComponent()
调用之后放置该代码。在那之前没有 myDateTimePicker
的实例。
关于c# - 如何在 DateTimePicker 中设置当前时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11784362/