Skip to main content

SchedulerDragData Class

Contains data passed to the target SchedulerControl in the drag-and-drop operation.

Namespace: DevExpress.XtraScheduler

Assembly: DevExpress.XtraScheduler.v24.1.Core.Desktop.dll

NuGet Package: DevExpress.Scheduler.CoreDesktop

Declaration

public class SchedulerDragData

The following members return SchedulerDragData objects:

Remarks

To perform a drag-and-drop operation, you should create an instance of the SchedulerDragData object, populate it with data and pass it to the DoDragDrop method of the control which initiates the operation.

The following example demonstrates a drag-and-drop operation between the GridControl and the SchedulerControl. An end-user drags a data row from the GridView and drops it onto the SchedulerControl, creating a new appointment from that data.

Example

private void gridViewTasks_MouseMove(object sender, MouseEventArgs e)
{
    GridView view = sender as GridView;
    if (e.Button == MouseButtons.Left && downHitInfo != null)
    {
        Size dragSize = SystemInformation.DragSize;
        Rectangle dragRect = new Rectangle(new Point(downHitInfo.HitPoint.X - dragSize.Width / 2,
            downHitInfo.HitPoint.Y - dragSize.Height / 2), dragSize);

        if (!dragRect.Contains(new Point(e.X, e.Y)))
        {
            view.GridControl.DoDragDrop(GetDragData(view), DragDropEffects.All);
            downHitInfo = null;
        }
    }
}
SchedulerDragData GetDragData(GridView view)
{
    int[] selection = view.GetSelectedRows();
    if (selection == null)
        return null;

    AppointmentBaseCollection appointments = new AppointmentBaseCollection();
    int count = selection.Length;
    for (int i = 0; i < count; i++)
    {
        int rowIndex = selection[i];
        Appointment apt = schedulerStorage.CreateAppointment(AppointmentType.Normal);
        apt.Subject = (string)view.GetRowCellValue(rowIndex, "Subject");
        apt.LabelKey = (int)view.GetRowCellValue(rowIndex, "Severity");
        apt.StatusKey = (int)view.GetRowCellValue(rowIndex, "Priority");
        apt.Start = DateTime.Now;
        apt.Duration = TimeSpan.FromHours((int)view.GetRowCellValue(rowIndex, "Duration"));
        apt.Description = (string)view.GetRowCellValue(rowIndex, "Description");
        appointments.Add(apt);
    }

    return new SchedulerDragData(appointments, 0);
}

Inheritance

Object
SchedulerDragData
See Also