Using 9.81 ActiveX
I keep getting the following error when the user press the forward or back button below is the error and below that is the code which produces the error. This problem does not show on my computer but only on some computers.
Exception:
System.Exception: TargetInvocationException in Navigate_Cal_Back_And_Forward()., CalendarControl.ViewType = xtpCalendarDayView, CalendarControl.ActiveView.DaysCount = 1, date range = 2006-11-02 00:00:00.000 to 2006-11-02 00:00:00.000
Stack Trace: JotmeApp.Calendar.CalendarBoardControl.Navigate_Cal_Back_And_Forward at JotmeApp.Calendar.CalendarBoardControl.Navigate_Cal_Back_And_Forward(Boolean forward) at JotmeApp.Calendar.CalendarBoardControl.Cal_Move_Forward_Click(Object sender, EventArgs e) 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.Label.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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Now the code which produces the error:
private void Navigate_Cal_Back_And_Forward(bool forward)
{
DateTime DateBegin = DateTime.Today;
DateTime DateEnd = DateTime.Today;
AxXtremeCalendarControl. AxDatePicker datePicker = this.mainFromRef.DatePicker;
if (datePicker.Selection.BlocksCount > 0)
{
DateBegin = datePicker.Selection[0].DateBegin;
DateEnd = datePicker.Selection[0].DateEnd;
}
switch (CalendarControl.ViewType)
{
case CalendarViewType.xtpCalendarDayView:
case CalendarViewType.xtpCalendarWorkWeekView:
//************ DEBUG VERSION ******************************************
int daysCount = CalendarControl.ActiveView.DaysCount;
DateTime rangeStart = DateBegin.AddDays(forward
? daysCount
: -daysCount
);
DateTime rangeEnd = DateEnd.AddDays(forward
? daysCount
: -daysCount
);
Application.DoEvents();
try
{
if (!CalendarControl.IsDisposed)
{
CalendarControl.DayView.ShowDays(rangeStart, rangeEnd);
}
}
catch (Exception ex)
{
throw new Exception(ex.GetType().Name + " in Navigate_Cal_Back_And_Forward()."
+ ", CalendarControl.ViewType = " + CalendarControl.ViewType.ToString()
+ ", CalendarControl.ActiveView.DaysCount = " + daysCount
+ ", date range = " + rangeStart.ToString("yyyy-MM-dd HH:mm:ss.fff")
+ " to " + rangeEnd.ToString("yyyy-MM-dd HH:mm:ss.fff")
);
}
//************ DEBUG VERSION ******************************************
break;
case CalendarViewType.xtpCalendarMonthView:
if (forward)
{
CalendarControl.ViewChanged -= new System.EventHandler(this.CalendarControl_ViewChanged);
CalendarControl.ActiveView.ShowDay(DateEnd.AddDays(5), true);
CalendarControl.ViewChanged += new System.EventHandler(this.CalendarControl_ViewChanged);
CalendarControl.ViewType = XtremeCalendarControl. CalendarViewType.xtpCalendarMonthView;
}
else
{
CalendarControl.ViewChanged -= new System.EventHandler(this.CalendarControl_ViewChanged);
CalendarControl.ActiveView.ShowDay(DateBegin.AddDays(-5), true);
CalendarControl.ViewChanged += new System.EventHandler(this.CalendarControl_ViewChanged);
CalendarControl.ViewType = XtremeCalendarControl. CalendarViewType.xtpCalendarMonthView;
}
break;
case CalendarViewType.xtpCalendarWeekView:
if (forward)
{
CalendarControl.ActiveView.ShowDay(DateEnd.AddDays(1), false);
}
else
{
CalendarControl.ActiveView.ShowDay(DateBegin.AddDays(-1), false);
}
break;
}
} |