4

Is it possible in anyway to specify which month is to be displayed first in a Month Calendar when you are displaying more than one month at a time?

I've seen similar questions but none have ever been answered, instead they have been given a workaround solution for their task at hand. I would like a simple "yes like this..." or "no because ..."

I've tried

monthCalendar.TodaysDate  
monthCalendar.MinDate     
monthCalendar.MaxDate    
monthCalendar.SetDate     
monthCalendar.SelectionStart    
monthCalendar.SelectionEnd

none of which properly move the month holding the selected date to the beginning. The month with the selected date is always the last month to be displayed which is no good when wanting to select future dates.

EDIT 5/29/2015

It appears that this problem only happens when trying to set the MonthCalendar with a future date of the current year (2015). A good example date to try is 7/20/2015.

Cody
  • 63
  • 10
  • it actually only happens if you select a date in the future, you can pick e.g. 1/20/2015 and it's fine. What I'm seeing is it always wants the current month to be the first month shown. – DrewJordan May 29 '15 at 12:37
  • Thanks @DrewJordan for catching that. And anything past the current month still does it as well. For example: If you choose a date five months past the current month with a (3,1) dimension it still acts the same. Even though the current month isn't being displayed. Very strange behavior. I am curious if this is the intended functionality. – Cody May 29 '15 at 13:18
  • Setting `MinDate` seems to work okay for me - what did you try with it? Maybe edit your question and add a complete example? – Damien_The_Unbeliever May 29 '15 at 13:35
  • Setting `MinDate` will not work for my required application they must be able to select any date from `DateTime.Now` to any future date. so just because I want the calendar to start 2 months past the current date doesn't mean i can just erase those 2 months so it starts in the correct place. – Cody May 29 '15 at 13:41
  • So when you said you "tried" `monthCalendar.MinDate` in your question, you were lying? – Damien_The_Unbeliever May 29 '15 at 13:58
  • No sir i am not lying. This is not a way to specify which month to start on. As it disables other months that will be needed. I am asking for a way to simply specify which month is displayed first without any adverse effects to the calendar. I consider your suggestion a workaround. Thank you for your input though. – Cody May 29 '15 at 15:17

1 Answers1

0

Yes, it is possible. I did it with a combination of SelectionStart and SelectionEnd.

this.monthCalendar1.CalendarDimensions = new System.Drawing.Size(4, 3);
this.monthCalendar1.FirstDayOfWeek = System.Windows.Forms.Day.Monday;
this.monthCalendar1.SelectionStart = new DateTime(1980, 5, 20);
this.monthCalendar1.SelectionEnd = new DateTime(1980, 5, 20);

Edit: It actually worked fine for me to just set the SelectionStart also, the only problem being that it selects ahead to the maximum selection count by default.

DrewJordan
  • 5,266
  • 1
  • 25
  • 39
  • Sorry but this code doesn't work all the way. Once you try to set the date to the current year (2015) is where the problem occurs. I will edit the question to reflect that the issue is only with the current year. – Cody May 29 '15 at 12:19