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

How to get DateTime from coordinates?

When I right-click on the schedule a ContextmenuEvent is triggered that has ContextMenuOpeningEventArgs.CurrentSelectedDate member set to DateTime corresponding to the current mouse location.
Is there a way to get DateTime based on coordinates without right-clicking the mouse? I couldn't find a public method for this. I want to implement drag-and-drop capability for the schedule, so a user can drop items on the schedule
using either a mouse or stylus. For that, I would like to get current mouse or stylus coordinates, pass them to this method and get DateTime. Can you please add such a method?

1 Reply

VR Vigneshkumar Ramasamy Syncfusion Team May 26, 2016 05:09 AM UTC

Hi Roman, 
Thanks for using Syncfusion product. 
As of now your requirement of getting time based on coordinates without using click event can be achieved by using MouseMove event for schedule control. Based on your requirement we have prepared a sample and please find the sample in the below link. 
Sample link: SfSchedule_DateTime
 
In the above sample we have used the below method to get the time based on the mouse point of ScheduleDayView. 
  
 private DateTime PointToDate(Point point) 
        { 
            draggingTime = new DateTime(); 
 
            var total = (point.Y / hourHeight); 
            var hour = (int)total; 
            var decimalvalue = (total - hour) * 60; 
            var min = schedule.TimeInterval != 0 ? (int)decimalvalue : 0; 
 
            if (total > 0) 
                draggingTime = draggingTime.AddHours(hour >= 0 ? hour : 0).AddMinutes(min); 
 
            return draggingTime; 
        } 
 
 
Regards 
Vigneshkumar R 


Loader.
Up arrow icon