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. Image for the cookie policy date

I want to get the date value year, month, and day of the scheduler navigation panel


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

3 Replies

JP Jagadeesan Pichaimuthu Syncfusion Team 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 



SL Smart law developer 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.



JP Jagadeesan Pichaimuthu Syncfusion Team 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

Loader.
Up arrow icon