Search code examples
c#memorymonthcalendar

How to get the previous selected date in a MonthCalendar in C#


let's say I have selected the date 12/22/2012

then I go on and select 11/19/2009.

I then try to so some code in

private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)

How would I be able to retrieve the date 12/22/2012? Would I need to keep some variables to do this? or is there something I could do to retrieve it?


Solution

  • Try and tweak this,Create a static class and a variable previousDate in it and put some initial value to it,

    private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e)
    {
        string previous = myStaticClass.previousDate;
        current = monthCalendar1.SelectionRange.Start.ToShortDateString();
        myStaticClass.previousDate=current ;
    }