I seem to have stumbled upon something that I can't explain and was
wondering if someone else could maybe help me figure out why this
happens. I've tried it in both VS2003 and with VS2005b2 and in both
cases the result is the same: an ArgumentOutOfRangeException.
Add the following to a blank WindowsForm in C# then call doStuff() from
the constructor or a buttonClick event. If you click on any date, it
pops up a messageBox (as it should) telling you the new date. Great. Now
try clicking one of the buttons to goto the next or previous month. At
first one messageBox shows up telling you the selection has changed to
the first of the next (or previous month), then when you click ok, it
seems to go haywire. It flips through about 19 months before crashing.
This is especially weird since it should only flip 1 month
(scrollChange=1). Changing the scrollChange has no effect, it just flips
through about 19 iterations of whatever scrollChange is set to. Ideas?
Thanks in advance,
-DS
---- Code below ----
private void doStuff()
{
MonthCalendar mc = new MonthCalendar();
mc.CalendarDimensions = new Size(1,1);
mc.Location = new Point(50, 50);
mc.MaxSelectionCount = 1;
mc.SetDate(DateTime.Parse("1 January 2005"));
mc.ScrollChange = 1;
this.Controls.Add(mc);
mc.DateChanged += new DateRangeEventHandler(mc_DateChanged);
}
void mc_DateChanged(object sender, DateRangeEventArgs e)
{
MessageBox.Show("date changed " + e.Start.ToString());
}