问题
I need to add seconds to the value of DateTimePicker. Can anyone tell me why the value remains unchanged after executing following code? And also I want to change the displayed value of DateTimePicker to its new value. This should be easy. mmm I dont know why.
Thanks.
protected override void updateTime(uint seconds)
{
this.dtPicAdmitDate.Value.AddSeconds(seconds);
}
回答1:
AddSeconds() will return a new DateTime object. Try:
this.dtPicAdmitDate.Value = this.dtPicAdmitDate.Value.AddSeconds(seconds);
来源:https://stackoverflow.com/questions/3090024/how-to-add-seconds-to-the-value-of-datetimepicker