如何将秒添加到DateTimePicker的值? [英] How to add seconds to the value of DateTimePicker?

查看:162
本文介绍了如何将秒添加到DateTimePicker的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要将秒添加到DateTimePicker的值。谁能告诉我为什么执行以下代码后该值保持不变?我也想将DateTimePicker的显示值更改为其新值。这应该很容易。嗯,我不知道为什么。

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.

谢谢。

protected override void updateTime(uint seconds)
{
    this.dtPicAdmitDate.Value.AddSeconds(seconds);
}


推荐答案

AddSeconds()将返回一个新的DateTime对象。试试:

AddSeconds() will return a new DateTime object. Try:

this.dtPicAdmitDate.Value = this.dtPicAdmitDate.Value.AddSeconds(seconds); 

这篇关于如何将秒添加到DateTimePicker的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆