Click here to Skip to main content
15,913,836 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
There is a datetimepicker named issueDate. Other datetimepicker as returnDate.
When user selects a date in issueDate the returnDate control has to automatically add months to the date selected in issueDate and show new calculated date in the returnDate control.
Please help me with the code

What I have tried:

I m looking for the code that will help me to solve this problem. I tried but nothing is working out.
Posted
Updated 7-Feb-17 1:59am
Comments
dirtyshooter 7-Feb-17 7:43am    
What calculated date you want? Please clarify your question
[no name] 7-Feb-17 9:28am    
"I m looking for the code", instead of 'looking' for code, why don't you try writing some?
"I tried but nothing is working out", funny, there doesn't seem to be a single line of C# code anywhere in your posting that demonstrates that you have tried anything at all. Adding months to a DateTime is simple so I doubt that you actually tried to do this yourself.
Pallavi 24 8-Feb-17 5:15am    
private void returnDate_ValueChanged(object sender, EventArgs e)
{
DateTime dt = new DateTime();
dt.AddMonths(6);

}
This is what I tried. But did not put up

// generate a ValueChanged Event for issueDate dateTimePicker and code like this it will do your job
private void issueDate_ValueChanged(object sender, EventArgs e)
        {
          
            DateTime issueDate = issueDate.Value;
            returnDate.Value = issueDate.AddMonths(2);
        }
 
Share this answer
 
Comments
Pallavi 24 8-Feb-17 5:25am    
Thank u so much. It worked.
Add ValueChanged event to the issueDate date time picker

C#
private void issueDate_ValueChanged(object sender, EventArgs e)
        {
            int monthsToAdd =10;
           var date =  issueDate.Value.AddMonths(monthsToAdd);
           returnDate.Value = date;
        }
 
Share this answer
 
v2
Comments
Pallavi 24 8-Feb-17 23:42pm    
Thank u for the help. But it did not work out.
Karthik_Mahalingam 9-Feb-17 0:06am    
ya, it should be issueDate
have updated my solution.

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