We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

I want to select a specific date from source code in the scheduler in windows forms;

Thread ID:

Created:

Updated:

Platform:

Replies:

146541 Aug 7,2019 03:13 PM UTC Sep 15,2019 08:36 AM UTC WinForms 9
loading
Tags: ScheduleControl
Smart law developer
Asked On August 7, 2019 03:13 PM UTC

hi. I want to select a specific date from source code in the scheduler;
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"
            SetViewRangeOfCalendar(firstSelectedTime.Year, firstSelectedTime.Month);
        } thank you;

Attachment: schedulegototoday20190808_1c795e2d.rar

Jagadeesan Pichaimuthu [Syncfusion]
Replied On August 8, 2019 11:31 AM UTC

Hi Smart, 
 
Thanks for using Syncfusion product.  
 
To move the selection programmatically, you can use the CurrentCell.MoveTo method after initialize the date value. Please refer the following code example and the sample.  
 
this.scheduleControl1.Calendar.DateValue = new DateTime(2019, 9, 8); 
this.scheduleControl1.Appearance.MonthShowFullWeek = true; 
this.scheduleControl1.GetScheduleHost().CurrentCell.MoveTo(2, 7); 
 
 
Please refer the below screen shot where the second row and seventh column is selected. 
 
 
 
In this above attached sample, MonthShowFullWeek property has enabled. If you have disabled this property, week days are covered by two rows. So, if you move to second row you could use the following code example.  
 
this.scheduleControl1.GetScheduleHost().CurrentCell.MoveTo(4, 7); 
 
Please refer the below forum for your reference. 
 
Note:  
To access the CurrentCell property, you could attach the Syncfusion.Grid.Windows.dll in your project. 
 
Let us know whether this helps also if you need any further assistance on this. 
 
Regards, 
Jagadeesan 


Smart law developer
Replied On August 8, 2019 04:22 PM UTC

The sample you sent does not change to the date I specified.
What I need is the scheduler grid to change to the date I entered.

Smart law developer
Replied On August 8, 2019 06:06 PM UTC

This works fine when you run the application, but if you change to a specific date during execution, the scheduler's date does not change to the desired date.

I attached the example project to the attached file,
I explained in screenshots what I needed.

Please solve.

Attachment: Schedule_Sample1030468972_8c04dc87.rar

Jagadeesan Pichaimuthu [Syncfusion]
Replied On August 9, 2019 11:21 AM UTC

Hi Smart, 
 
Thanks for your update. 
 
We have checked your requirements and modified the sample based on your scenarios. Please find the attached sample and let us know if you have any other queries. 
 
1. Code to update the month view and set the focus to selected date: 
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 }); 
    } 
} 
 
2. Code to update the current month and set focus in NavigationPanel calendar: 
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; 
    } 
} 
 
Sample link: 
 
 
Let us know whether this helps also if you need any further assistance on this. 
 
Regards, 
Jagadeesan 


Smart law developer
Replied On August 10, 2019 09:39 AM UTC

Thank you for the sample you sent us.
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

Keerthivasan Asokkumar [Syncfusion]
Replied On August 12, 2019 12:56 PM UTC

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.


Smart law developer
Replied On September 10, 2019 03:31 PM UTC

Hi;
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" newmanjoo@nate.com

Attachment: Scheduler_20190911_001407_51e50953.rar

Arulpriya Ramalingam [Syncfusion]
Replied On September 11, 2019 02:55 PM UTC

Hi Smart, 
 
Thanks for your update. 
 
We could reproduce the issue at our end and we are working on this with high priority. We need some more time to validate the use case at our end and we will update you the proper details on 13th September, 2019. 
 
Regards, 
Arulpriya 


Arulpriya Ramalingam [Syncfusion]
Replied On September 15, 2019 08:36 AM UTC

Hi Smart, 
 
Thanks for your patience. 
 
We have analyzed the reported use case at our end with the sample and it occurred due to the AdjustSelectionsByMonth() method was not updated properly when the DateValue is changed manually through the button click. In order to overcome this use case, the label of header text can be updated properly by using the AdjustSelectionsByMonth() method. We have modified the sample based on your requirement and please make use of the below code and modified sample. 
 
Code example 
 
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); 
    } 
} 
 
 
Arulpriya 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon