Get start and end datetime from GanttView PreviewDragStart

2 posts, 1 answers
  1. Damon
    Damon avatar
    2 posts
    Member since:
    Aug 2012

    Posted 23 May Link to this post

    //GanttView PreviewDragStart

    private void DragDropService_PreviewDragStart(object sender, PreviewDragStartEventArgs e)
    {

    if (e.DragInstance is GanttViewTaskElement)
          {
            e.CanStart = true;  

    //want to get start and end datetime
          }

    }

    From above event how can i get Start and End datetime from e.DragInstance

  2. Answer
    Dess
    Admin
    Dess avatar
    1602 posts

    Posted 25 May Link to this post

    Hello Damon,

    Thank you for writing. 

    You can find below a sample code snippet demonstrating how to access the start/end date of the dragged task element:
     
    this.radGanttView1.GanttViewElement.DragDropService.PreviewDragStart += DragDropService_PreviewDragStart;
     
    private void DragDropService_PreviewDragStart(object sender, Telerik.WinControls.PreviewDragStartEventArgs e)
    {
        GanttViewTaskElement taskElement = e.DragInstance as GanttViewTaskElement;
        if (taskElement != null)
        {
            e.CanStart = true;
            GanttViewDataItem item = ((GanttViewTaskItemElement)taskElement.Parent).Data;
            Console.WriteLine("Start: " + item.Start + " End: " + item.End);
        }
    }

    I hope this information helps. Should you have further questions I would be glad to help.

    Regards,
    Dess
    Telerik
    Check out the Windows Forms project converter, which aids the conversion process from standard Windows Forms applications written in C# or VB to Telerik UI for WinForms.For more information check out this blog post and share your thoughts.
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top