Click here to Skip to main content
15,885,365 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Updated 17-Feb-17 8:26am

1 solution

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));


Thanks,
Valery
 
Share this answer
 
Comments
Karthik_Mahalingam 17-Feb-17 23:42pm    
5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900