private void btnGoto_Click(object sender, EventArgs e)
{
DateTime newDate = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day);
//To navigate dates at run time.
scheduleControl1.Calendar.DateValue = newDate;
scheduleControl1.Refresh();
} |
DateTime newDate = new DateTime(dateTimePicker1.Value.Year, dateTimePicker1.Value.Month, dateTimePicker1.Value.Day);
//To switch to day view when the date is selected programmatically.
scheduleControl1.SwitchToScheduleViewTypeDay(newDate); |
private void btnGoto_Click(object sender, EventArgs e)
{
if (this.dateTimePicker1.Value != this.scheduleControl1.Calendar.DateValue)
{
DateTime date = this.dateTimePicker1.Value;
int monthDiff = ((date.Year - this.scheduleControl1.Calendar.DateValue.Year) * 12) + date.Month - this.scheduleControl1.Calendar.DateValue.Month;
this.scheduleControl1.Calendar.DateValue = date;
this.scheduleControl1.Calendar.AdjustSelectionsByMonth(monthDiff > 0 ? monthDiff - 1 : monthDiff + 1);
var method = this.scheduleControl1.GetScheduleHost().GetType().GetMethod("SetCurrentCellInView", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
if (method != null)
{
this.scheduleControl1.GetScheduleHost().Model.ResetCurrentCellInfo();
method.Invoke(this.scheduleControl1.GetScheduleHost(), new object[] { date });
}
this.scheduleControl1.PerformSwitchToScheduleViewTypeClick(ScheduleViewType.WorkWeek);
}
} |