Click here to Skip to main content
15,893,190 members
Please Sign up or sign in to vote.
2.50/5 (3 votes)
See more:
Hai every one,
I am doing a project.In that in one of the text box i am entering one date.I have another text box, i want to add 15 days to the date entered in the text box1 and automatically display in text box2 when focus is moved out of text box1.Please any one help me in accomplishing his task.

Thanks in advance.
Posted

See these two links

TextBox.TextChanged Event[^]

DateTime.AddDays Method[^]

In textchanged event of first textbox,add required days to first date and assign it to second textbox. Take care of date format while performing this operation.

This will be useful : String was not recognized as a valid DateTime.[^]

Regards..
 
Share this answer
 
v2
Simple:
If you have any question, just comment my answer :)
C#
string s = TextBox1.Text;
var date = DateTime.Parse(s);
TextBox2.Text = date.AddDays(15).ToShortDateString();
 
Share this answer
 
 
Share this answer
 
v2
DateTime Currdt = Convert.ToDateTime(System.DateTime.Now.ToString());

Currdt=Currdt.AddDays(15);


Explanation


Curretn system data Currdt="01/10/2013"



after this Currdt="16/10/2013"
 
Share this answer
 
v2

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