菜鸟求指导: 如何设置DateTimePicker中Value值
部分代码如下:
//部分DateTimePicker控件编辑中的代码
//用于设置关机时间
this.SetupTime.CustomFormat = "00:00:00";
this.SetupTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.SetupTime.Value = new System.DateTime(2011, 2, 22,0, 0, 0, 0);
//用于设置关机日期
this.SetupDate.CustomFormat = "2011-2-22";
this.SetupDate.Format = System.Windows.Forms.DateTimePickerFormat.Custom;
this.SetupDate.Value = new System.DateTime(2011, 2, 22);
//判断系统时间是否和设置的关机时间一致
if (CurrDate == SetupDate.ToString() && CurrTime == SetupTime.ToString())
CloseComputer();
其中:
string CurrDate = System.DateTime.Today.ToShortDateString();
string CurrTime = System.DateTime.Now.ToLongTimeString();
问题:设置好关机时间后,到了该时间还是不能关机。单步运行发现SetupTime和SetupDate的value都是 2011-2-11 00:00:00
请问各位高手我是不是在DateTimePicker控件中该如何设置,才能实现上面那个判断语句呢。