I want to select a specific date from source code in the scheduler in windows forms;
I looked for various properties but couldn't solve them;
my example code) private void btnToday_Click(object sender, EventArgs e)
{
//scdCtrl.Calendar.SelectedDates.Clear();
scdCtrl.Calendar.DateValue = DateTime.Now; // 2019-08-08
scdCtrl.GetScheduleHost().Calendar.DateValue = DateTime.Now;
} private void Calendar_DateValueChanged(object sender, EventArgs e)
{
DateTime firstSelectedTime = scdCtrl.Calendar.SelectedDates[0]; // ========> this date : 2019-09-01, i want "2019-08-08"
} thank you;
Attachment: schedulegototoday20190808_1c795e2d.rar
|
this.scheduleControl1.Calendar.DateValue = new DateTime(2019, 9, 8);
this.scheduleControl1.Appearance.MonthShowFullWeek = true;
this.scheduleControl1.GetScheduleHost().CurrentCell.MoveTo(2, 7); |
|
this.scheduleControl1.GetScheduleHost().CurrentCell.MoveTo(4, 7); |
What I need is the scheduler grid to change to the date I entered.
I attached the example project to the attached file,
I explained in screenshots what I needed.
Please solve.
Attachment: Schedule_Sample1030468972_8c04dc87.rar
|
private void btnGoto_Click(object sender, EventArgs e)
{
DateTime date = this.dateTimePicker1.Value;
int monthDiff = date.Month - this.scheduleControl1.Calendar.DateValue.Month;
this.scheduleControl1.Calendar.DateValue = date;
this.scheduleControl1.Calendar.AdjustSelectionsByMonth(monthDiff > 0 ? monthDiff - 1 : monthDiff + 1);
this.scheduleControl1.ResetProvider(this.scheduleControl1.ScheduleType);
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 });
}
} |
|
scheduleControl1.Calendar.CalenderGrid.QueryCellInfo += CalenderGrid_QueryCellInfo1;
private void CalenderGrid_QueryCellInfo1(object sender, Syncfusion.Windows.Forms.Grid.GridQueryCellInfoEventArgs e)
{
DateTime day = this.dateTimePicker1.Value;
DateTime isdate;
if (!string.IsNullOrEmpty(e.Style.CellValue.ToString()) && DateTime.TryParse(e.Style.CellValue.ToString(),out isdate) &&
isdate == day)
{
e.Style.BackColor = this.scheduleControl1.Appearance.NavigationCalendarTodayBackColor;
e.Style.TextColor = this.scheduleControl1.Appearance.NavigationCalendarTodayTextColor;
}
} |
When I press the "Go" button in that sample, it sometimes moves to that date, but most attempts do not move to the date indicated by the datetimepicker.
Attach the sample you sent me, and attach the video I played.
Please debug;
Attachment: Scheduler_20190810_182903_e540fbb.rar
Hi Smart,
Thanks for your update.
We have analyzed the sample and resolved the reported issue. Please find the attached sample and let us know if you have any other queries.
Please replace old code with highlighted changes in your sample.
|
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 }); } } } |
Sample link : https://www.syncfusion.com/downloads/support/directtrac/general/ze/ModifiedSample2123389811.zip
Let us know whether this helps you and also if you need any further assistance on this.
Regards,
Keerthivasan A.
I write after a long time.
I couldn't do scheduler coding because of other urgent work.
I tested it with the sample code you sent me last.
The conclusion is not correct.
Attach a video.
It should be coded in detail.
Thank you. ps. my email address : "kim" [email protected]
Attachment: Scheduler_20190911_001407_51e50953.rar
|
private void Calendar_DateValueChanged(object sender, EventArgs e)
{
DateTime firstSelectedTime = scheduleControl1.Calendar.SelectedDates[0];
SetViewRangeOfCalendar(firstSelectedTime.Year, firstSelectedTime.Month);
DateSelections SelectedDates = scheduleControl1.Calendar.SelectedDates;
//To update the headertext label
if (SelectedDates[SelectedDates.Count - 1] > scheduleControl1.Calendar.BottomRightDate.AddDays(-1))
{
this.scheduleControl1.Calendar.AdjustSelectionsByMonth(-1);
}
} |
- 9 Replies
- 4 Participants
-
SL Smart law developer
- Aug 7, 2019 03:13 PM UTC
- Sep 15, 2019 08:36 AM UTC