Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
465
UltraWinSchedule: Drag drop
posted

Hi,

As shown in the snapshot, I am using UltraWinTree.UltraTree in the Search Panel and UltraWinSchedule.UltraWeekView.

I want to perform drag drop operation i.e. when i select a node in Search Panel, then drag  it and drop on the UltraWeekView it should save the appointment with that node name.

Is it possible to perform drag drop from ultratree to ultraweekview? If yes possible could you provide me solution  on how to do it  or a sample code?

  • 22852
    Suggested Answer
    Offline posted

    Zalak,

    The following is a very simple implementation that shows how to do drag and drop from a tree to an UltraDayView:

    public Form1()
    {
        InitializeComponent();
        this.ultraTree1.SelectionDragStart += new EventHandler(ultraTree1_SelectionDragStart);
        this.ultraDayView1.DragOver += new DragEventHandler(ultraDayView1_DragOver);
        this.ultraDayView1.DragDrop += new DragEventHandler(ultraDayView1_DragDrop);
        for (int i = 0; i < 10; i++)
        {
            this.ultraTree1.Nodes.Add("node" + i.ToString(), "node" + i.ToString());
        }

        this.ultraDayView1.AllowDrop = true;
    }

    void ultraDayView1_DragDrop(object sender, DragEventArgs e)
    {
        SelectedNodesCollection nodes = e.Data.GetData(typeof(SelectedNodesCollection)) as SelectedNodesCollection;
        if (nodes != null && nodes.Count > 0)
        {
            TimeSlot ts = this.ultraDayView1.GetTimeSlotFromPoint(this.ultraDayView1.PointToClient(new Point(e.X, e.Y)));
            DateTime startTime = this.ultraCalendarInfo1.ActiveDay.Date.AddHours(ts.StartTime.Hour);
            DateTime endTime = startTime.AddHours(2);
            this.ultraCalendarInfo1.Appointments.Add(new Appointment(startTime, endTime)
            {
                Subject = nodes[0].Text,
                Description = nodes[0].Text
            });
        }
    }

    void ultraDayView1_DragOver(object sender, DragEventArgs e)
    {
        e.Effect = DragDropEffects.Move;
    }

    void ultraTree1_SelectionDragStart(object sender, EventArgs e)
    {
        this.ultraTree1.DoDragDrop(this.ultraTree1.SelectedNodes, DragDropEffects.Move);
    }
    }

    I have also attached a sample showing this. 

    Let me know if you have any questions.

    WindowsFormsApplication3.zip