How to add seconds to the value of DateTimePicker?

元气小坏坏 提交于 2019-12-25 03:27:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!