I have a c#.net gui program that I have two dateTimePicker’s and I would like to make it where if I change one picker it updates the next picker to show one week later.
I have tried:
System.DateTime today = System.DateTime.Now;
System.DateTime answer = today.AddDays(7);
and:
System.DateTime today = System.DateTime.Now;
System.TimeSpan duration = new System.TimeSpan(7, 0, 0, 0);
System.DateTime answer = today.Add(duration);
<dateTimePickerName>.Value = answer;
and a third try:
<dateTimePickerName>.Value = <OriginalPickerName>.Value.AddDays(7,0);
And so far the only accomplishment I have gotten is when I run the gui the second picker will automatically go to one week from today since the first picker is set to today but when I change the first date the second will not update.
Create a method that does the work of “Add 7 days to the 2nd picker”.
When you start up your project, run that method.
on the DateChanged event on the DateTime picker, run that method.
On my phone so quick example of the method to call:
Then call that method on date changed, and on form load.