corelibraries-devexpress-dot-xtrascheduler-0d8180dc.md
Contains data passed to the target SchedulerControl in the drag-and-drop operation.
Namespace : DevExpress.XtraScheduler
Assembly : DevExpress.XtraScheduler.v25.2.Core.Desktop.dll
NuGet Package : DevExpress.Scheduler.CoreDesktop
public class SchedulerDragData
Public Class SchedulerDragData
The following members return SchedulerDragData objects:
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.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/winforms-scheduler-drag-drop-appointments-from-grid
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);
}
Private Sub gridViewTasks_MouseMove(ByVal sender As Object, ByVal e As MouseEventArgs) Handles gridViewTasks.MouseMove
Dim view As GridView = TryCast(sender, GridView)
If e.Button = MouseButtons.Left AndAlso downHitInfo IsNot Nothing Then
Dim dragSize As Size = SystemInformation.DragSize
Dim dragRect As New Rectangle(New Point(downHitInfo.HitPoint.X - dragSize.Width \ 2, downHitInfo.HitPoint.Y - dragSize.Height \ 2), dragSize)
If Not dragRect.Contains(New Point(e.X, e.Y)) Then
view.GridControl.DoDragDrop(GetDragData(view), DragDropEffects.All)
downHitInfo = Nothing
End If
End If
End Sub
Private Function GetDragData(ByVal view As GridView) As SchedulerDragData
Dim selection() As Integer = view.GetSelectedRows()
If selection Is Nothing Then
Return Nothing
End If
Dim appointments As New AppointmentBaseCollection()
Dim count As Integer = selection.Length
For i As Integer = 0 To count - 1
Dim rowIndex As Integer = selection(i)
Dim apt As Appointment = schedulerStorage.CreateAppointment(AppointmentType.Normal)
apt.Subject = CStr(view.GetRowCellValue(rowIndex, "Subject"))
apt.LabelKey = CInt((view.GetRowCellValue(rowIndex, "Severity")))
apt.StatusKey = CInt((view.GetRowCellValue(rowIndex, "Priority")))
apt.Start = Date.Now
apt.Duration = TimeSpan.FromHours(CInt((view.GetRowCellValue(rowIndex, "Duration"))))
apt.Description = CStr(view.GetRowCellValue(rowIndex, "Description"))
appointments.Add(apt)
Next i
Return New SchedulerDragData(appointments, 0)
End Function
Object SchedulerDragData
See Also