ユーザーが
CalendarAppointmentCellType のドラッグハンドラをドラッグしているときに発生します。
イベント ハンドラが、このイベントに関連するデータを含む、AppointmentCellDraggingEventArgs 型の引数を受け取りました。次の AppointmentCellDraggingEventArgs プロパティには、このイベントの固有の情報が記載されます。
次のサンプルコードは、このイベントを使用して予定の日付範囲を制限する方法を示します。このサンプルコードは、
CalendarAppointmentCellType クラスに示されている詳細なコード例の一部を抜粋したものです。
void gcCalendarGrid_AppointmentCellDragging(object sender, AppointmentCellDraggingEventArgs e)
{
//The following code will make the appointment limited between 2014/1/1 and 2014/1/31, and the original appointment date cannot be changed to shorter.
if (e.StartCellPosition.RowIndex == 1 && e.StartCellPosition.ColumnIndex == 0)
{
if (e.DraggingHandle == HandlePosition.Left)
{
if (e.TargetCellPosition.Date >= new DateTime(2014, 1, 1) && e.TargetCellPosition.Date <= e.StartCellPosition.Date)
{
e.AllowDrop = true;
}
else
{
e.AllowDrop = false;
}
}
else if(e.DraggingHandle == HandlePosition.Right)
{
if (e.TargetCellPosition.Date <= new DateTime(2014, 1, 31) && e.TargetCellPosition.Date >= e.EndCellPosition.Date)
{
e.AllowDrop = true;
}
else
{
e.AllowDrop = false;
}
}
}
}
Private Sub gcCalendarGrid_AppointmentCellDragging(sender As Object, e As AppointmentCellDraggingEventArgs)
'The following code will make the appointment limited between 2014/1/1 and 2014/1/31, and the original appointment date cannot be changed to shorter.
If e.StartCellPosition.RowIndex = 1 AndAlso e.StartCellPosition.ColumnIndex = 0 Then
If e.DraggingHandle = HandlePosition.Left Then
If e.TargetCellPosition.[Date] >= New DateTime(2014, 1, 1) AndAlso e.TargetCellPosition.[Date] <= e.StartCellPosition.[Date] Then
e.AllowDrop = True
Else
e.AllowDrop = False
End If
ElseIf e.DraggingHandle = HandlePosition.Right Then
If e.TargetCellPosition.[Date] <= New DateTime(2014, 1, 31) AndAlso e.TargetCellPosition.[Date] >= e.EndCellPosition.[Date] Then
e.AllowDrop = True
Else
e.AllowDrop = False
End If
End If
End If
End Sub