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 get the date value year, month, and day of the scheduler navigation panel

Thread ID:

Created:

Updated:

Platform:

Replies:

145470 Jun 24,2019 09:15 AM UTC Jun 28,2019 10:49 AM UTC WinForms 3
loading
Tags: ScheduleControl
Smart law developer
Asked On June 25, 2019 06:56 AM UTC


1. I want to get the date value year, month, and day of the scheduler navigation panel. (Red box in picture of attachment)

2. I want to know how to parse full date time value (yyyy-mm-dd), not parse (mm-dd)

Your old sample is a year bug;
------ your old bug example ------
this.scheduleControl1.GetScheduleHost (). DrawCellDisplayText + = newSyncfusion.Windows.Forms.Grid.GridDrawCellDisplayTextEventHandler (Form1_DrawCellDisplayText);
  
string displayText = null;
void Form1_DrawCellDisplayText (object sender, Syncfusion.Windows.Forms.Grid.GridDrawCellDisplayTextEventArgs e)
{
    if (e.RowIndex == 1 && e.ColIndex == 1)
        displayText = e.Style.Text;
}

// displayText value: "dd mm" => lost year value;

Thank you.

Attachment: ScheduleNaviControl_e0086168.rar

Jagadeesan Pichaimuthu [Syncfusion]
Replied On June 25, 2019 01:55 PM UTC

Hi Smart, 
  
Thanks for using Syncfusion product. 
  
Query 
Response 
I want to get the date value year, month, and day of the scheduler navigation panel. (Red box in picture of attachment) 
To get the selected date value, you could use the ControlText property. Please refer the following code example.  
 
string text =this.scheduleControl1.GetScheduleHost().CurrentCell.Renderer.ControlText;  
String date = text.Substring(0, text.IndexOf('\n'));  
 
  
  
I want to know how to parse full date time value (yyyy-mm-dd), not parse (mm-dd) 
To get the date value with year, you could parse the date with the date format. Please refer the following code example. 
  
private void Form1_DrawCellDisplayText(object sender, Syncfusion.Windows.Forms.Grid.GridDrawCellDisplayTextEventArgs e) 
{ 
    if (e.RowIndex == 1 && e.ColIndex == 1) 
    { 
        displayText = e.Style.Text; 
        String date = displayText.Substring(0, displayText.IndexOf('\n')); 
        DateTime dateTime; 
        if (DateTime.TryParse(date, out dateTime)) 
        { 
            DateTime dateValue = newDateTime(this.scheduleControl1.Calendar.DateValue.Year, dateTime.Month, dateTime.Day); 
        } 
    } 
} 
  
  
Please get back to us if you need any further assistance on this. 
  
Regards, 
Jagadeesan 


Smart law developer
Replied On June 27, 2019 04:21 PM UTC

        private void Form1_DrawCellDisplayText(object sender, Syncfusion.Windows.Forms.Grid.GridDrawCellDisplayTextEventArgs e)
        {
            if (e.RowIndex == 1 && e.ColIndex == 1)
            {
                displayText = e.Style.Text;
                String date = displayText.Substring(0, displayText.IndexOf('\n'));
                DateTime dateTime;
                if (DateTime.TryParse(date, out dateTime))
                {
                    DateTime dateValue = new DateTime(this.scheduleControl1.Calendar.DateValue.Year, dateTime.Month, dateTime.Day);
                    Console.Out.WriteLine($"dateValue={dateValue.ToString()}");
                }
            }
        }

----------------------------------------------
output

dateValue=2019-07-29 오전 12:00:00
dateValue=2019-07-29 오전 12:00:00
dateValue=2019-07-29 오전 12:00:00
dateValue=2019-07-29 오전 12:00:00
dateValue=2019-07-29 오전 12:00:00
dateValue=2019-07-29 오전 12:00:00
dateValue=2019-07-29 오전 12:00:00
dateValue=2019-07-01 오전 12:00:00
dateValue=2019-07-01 오전 12:00:00
dateValue=2019-07-01 오전 12:00:00
dateValue=2019-07-01 오전 12:00:00
dateValue=2019-07-01 오전 12:00:00
dateValue=2019-07-01 오전 12:00:00
dateValue=2019-07-29 오전 12:00:00
dateValue=2019-07-29 오전 12:00:00
dateValue=2019-07-01 오전 12:00:00
dateValue=2019-07-01 오전 12:00:00
dateValue=2019-07-01 오전 12:00:00
dateValue=2019-07-01 오전 12:00:00
dateValue=2019-07-01 오전 12:00:00
dateValue=2019-07-01 오전 12:00:00

If the current month is not the same as the above result, the event will not occur.


Jagadeesan Pichaimuthu [Syncfusion]
Replied On June 28, 2019 10:49 AM UTC

Hi Smart,  
 
Thanks for your update.  
 
To change the display text format of date (mm/dd -> mm/dd/yyyy), use the DrawCell event of ScheduleGrid instead of DrawCellDisplayText event and override the Text value as like below code.  
 
Code snippet:  
this.scheduleControl1.GetScheduleHost().DrawCell += Form1_DrawCell;  
 
private void Form1_DrawCell(object sender, Syncfusion.Windows.Forms.Grid.GridDrawCellEventArgs e)  
{  
    if (e.RowIndex == 1 && e.ColIndex == 1)  
    {  
        displayText = e.Style.Text;  
        String date = displayText.Substring(0, displayText.IndexOf('\n'));  
        DateTime dateTime;  
        if (DateTime.TryParse(date, out dateTime))  
        {  
            DateTime dateValue = newDateTime(this.scheduleControl1.Calendar.DateValue.Year, dateTime.Month, dateTime.Day);  
            e.Style.Text = dateValue.ToShortDateString();  
        }  
    }  
}  
 
Please let us know, if we misunderstand anything from your requirements.  
 
Regards,  
Jagadeesan

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