Contents
- Use case scenario
- Property
- Event
- Adding this support to an application
Having trouble getting help?
Contact Support
Contact Support
Item Dragging Context in the ItemChanging event in Scheduler
21 Jan 20253 minutes to read
This feature provides support to detect the dragging context when an item is dropped in the schedule part or calendar part. It also enables you to cancel the needed items through the ItemChanging event.
Use case scenario
In ItemChanging event, through the ItemDragHitContext enumeration, you can detect the dragging context (Schedule or Calendar) and cancel the needed items.
Property
Property | Description | Data Type |
---|---|---|
ItemDragHitContext | Specifies where the mouse is during an appointment drag in a week or month view. | enum |
Event
Event | Parameters | Description |
---|---|---|
ItemChanging | object sender, ScheduleAppointmentCancelEventArgs e | Occurs after an IScheduleAppointment is modified. |
Sample link
You can get the schedule sample from the following online location:
http://samples.syncfusion.com/windowsforms
Adding this support to an application
The following steps help you to get the target part in the Schedule control while dragging:
- Create a Schedule control enabled sample application.
- Add appointments in that schedule grid.
- Hook the
ItemChanging
event.
this.scheduleControl1.ItemChanging += new ScheduleAppointmentChangingEventHandler(scheduleControl1_ItemChanging);
AddHandler scheduleControl1.ItemChanging, AddressOf scheduleControl1_ItemChanging
Get the drag hit context with the following code.
void scheduleControl1_ItemChanging(object sender, ScheduleAppointmentCancelEventArgs e)
{
if (e.Action == ItemAction.ItemDrag)
{
Console.WriteLine("Dropped Area :" + e.ItemDragHitContext);
}
}
Private Sub scheduleControl1_ItemChanging(ByVal sender As Object, ByVal e As ScheduleAppointmentCancelEventArgs)
If e.Action = ItemAction.ItemDrag Then
Console.WriteLine("Dropped Area :" + e.ItemDragHitContext.ToString())
End If
End Sub
You can cancel the dropped item using the ItemDragHitContext property.
void scheduleControl1_ItemChanging(object sender, ScheduleAppointmentCancelEventArgs e)
{
if (e.ItemDragHitContext == ItemDragHitContext.Calendar)
e.Cancel = true;
}
Private Sub scheduleControl1_ItemChanging(ByVal sender As Object, ByVal e As ScheduleAppointmentCancelEventArgs)
If e.ItemDragHitContext = ItemDragHitContext.Calendar Then
e.Cancel = True
End If
End Sub