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
450
Drag and Drop into a UltraDayView
posted

 

Hey Guys,

 Looking  for some guidance here about drag and drop onto a ultradayview.

i have a list view with people’s names on it and i want to be able to drag from the list view and drop onto the ultradayview and it creates the entry/appointment for that person where i have dropped it.

 I have setup the events for the listview for drag enter and have been able to create the event for dragdrop for the ultradayview, but i can not work out how to work out where i have dropped it and how to create the appointment for it

Thanks in advance for any help or guidance you can offer

Cheers
Phil 

Parents
  • 2677
    posted

    Hey,

     There is actually some pretty neat methods off of the DayView conrol that make this process very simple.  There is a GetTimeSlotFromPoint method which takes the point where you did the drop which you have within the DragDrop event.  Then there is a GetVisibleDayFromPoint to get the day from the point at which we dropped.  Then we can use this information to create an appointment and add it to the DayView.  Here is a code snippet.  I have also attached a project created with NetAdvantage 2008 Vol.2 and VS2008.  Hope this helps. 

    private void ultraDayView1_DragDrop(object sender, DragEventArgs e)

    {

    Point clientPoint = this.ultraDayView1.PointToClient(Form1.MousePosition);

    TimeSlot tslot = this.ultraDayView1.GetTimeSlotFromPoint(clientPoint);

     

    if (tslot != null)

    {

    VisibleDay vday = this.ultraDayView1.GetVisibleDayFromPoint(clientPoint);if (vday != null)

    {

    Appointment appt = new Appointment(new DateTime(vday.Date.Year, vday.Date.Month, vday.Date.Day, tslot.StartTime.Hour, tslot.StartTime.Minute, tslot.StartTime.Second),

    new DateTime(vday.Date.Year, vday.Date.Month, vday.Date.Day, tslot.EndTime.Hour, tslot.EndTime.Minute + 1, tslot.EndTime.Second));

    appt.Subject = ((ListViewItem)e.Data.GetData(typeof(ListViewItem))).Text;

    this.ultraCalendarInfo1.Appointments.Add(appt);

    }

    else

    {

    MessageBox.Show("Visible Day not found!");

    }

    }

    else

    {

    MessageBox.Show("TimeSlot not found!");

    }

    }

     

    WinDayViewDragDropFromListView.zip
Reply Children
No Data