如何通过在datetimepicker中添加天数来查找未来日期? [英] How do I find future date by adding days into a datetimepicker?

查看:94
本文介绍了如何通过在datetimepicker中添加天数来查找未来日期?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,



我正在学习C#windows应用程序。我有一个WinForm,它包含一个DateTimePicker,一个TextBox和一个CommandButton。



DateTimePicker显示当前日期。现在,当用户输入TextBox中的天数(例如17)并按下CommandButton时,结果日期应该是当前日期+17天。



请帮帮我怎样才能做到这一点。



谢谢。



Mayank Jani。



我尝试了什么:



我可以找到两个日期之间有两个差异日期时间选择器或文本框但我无法理解如何在日期中添加天数以查找结果日期。

Hello,

I am learning C# windows application. I have a WinForm which contains a DateTimePicker, a TextBox and a CommandButton.

the DateTimePicker shows current date. Now, when a user enters number of days in the TextBox (e.g. 17) and presses the CommandButton, the result date should be the current date + 17 days.

Please help me how can i do this.

Thank You.

Mayank Jani.

What I have tried:

I can find the difference between two dates with two date time pickers or text boxes but i can not understand how to add days in a date to find resulting date.

推荐答案

您好,



DateTimePicker选择日期存储在Value属性中。你只需要增加它。



Hello,

The DateTimePicker selected date is stored in the Value property. You just need to increase it.

dateTimePicker1.Value = dateTimePicker1.Value.AddDays(Convert.ToInt32(textBox1.Text));





谢谢,

Valery



Thanks,
Valery


这篇关于如何通过在datetimepicker中添加天数来查找未来日期?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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