Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic MonthRange exception going back a month (Read 4016 times)
BenWTS
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 8
Joined: Jun 19th, 2008
MonthRange exception going back a month
Jul 24th, 2008 at 6:42pm
Print Post  
I'm getting the following exception when using the MonthRange View with 2 months displayed and clicking the back button to go back 1 month.

Quote:
System.ArgumentOutOfRangeException was unhandled
Message="The added or subtracted value results in an un-representable DateTime.\r\nParameter name: t"
Source="mscorlib"
ParamName="t"
StackTrace:
at System.DateTime.op_Addition(DateTime d, TimeSpan t)
at MindFusion.Scheduling.WinForms.xd60e986cf5aae4b8.x403992eb898c7826()
at MindFusion.Scheduling.WinForms.xd60e986cf5aae4b8.xc60c1099e9d81838(Object xe0292b9ed559da7d, EventArgs xfbf34718e704c6bc)
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNat
iveMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at TestMonthRange.Program.Main() in C:\TestMonthRange\Program.cs:line 17
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()


I reproduced it with some simple code like the following:

public Form1()
{
InitializeComponent();
mfMonthRange.BeginInit();
mfMonthRange.Date = DateTime.Today;
mfMonthRange.Selection.Set(DateTime.Today);
mfMonthRange.EndInit();
mfMonthRange.Invalidate();
}

Here is the settings for the month range control in InitializeComponent:

//
// mfMonthRange
//
this.mfMonthRange.CurrentTime = new System.DateTime(2008, 4, 13, 0, 0, 0, 0);
this.mfMonthRange.CurrentView = MindFusion.Scheduling.WinForms.CalendarView.MonthRange;
this.mfMonthRange.Date = new System.DateTime(2008, 4, 17, 0, 0, 0, 0);
this.mfMonthRange.DateTimeFormat = ((System.Globalization.DateTimeFormatInfo)(resources.GetObject("mfMonthRange.Dat
eTimeFormat")));
this.mfMonthRange.Dock = System.Windows.Forms.DockStyle.Fill;
this.mfMonthRange.EndDate = new System.DateTime(((long)(0)));
this.mfMonthRange.Location = new System.Drawing.Point(0, 0);
this.mfMonthRange.MonthRangeSettings.MonthsPerRow = 1;
this.mfMonthRange.MonthRangeSettings.NumberOfMonths = 2;
this.mfMonthRange.MonthRangeSettings.ScrollInterval = 1;
this.mfMonthRange.MonthRangeSettings.VisibleRows = 2;
this.mfMonthRange.Name = "mfMonthRange";
this.mfMonthRange.Size = new System.Drawing.Size(292, 266);
this.mfMonthRange.TabIndex = 4;
this.mfMonthRange.Theme = MindFusion.Scheduling.WinForms.ThemeType.Windows2003;

This is for .NET 2.0.

Hopefully I just have some incorrect settings somewhere.

Thanks
Ben
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: MonthRange exception going back a month
Reply #1 - Jul 25th, 2008 at 7:09am
Print Post  
Remove the following line from your initialization code:

Code
Select All
this.mfMonthRange.EndDate = new System.DateTime(((long)(0))); 


This line is generated when you accidentally delete the value of the Calendar.EndDate property in the property grid.

Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint