Ticket T1282707
Visible to All Users

dxsch:SchedulerControl allow to drop appointment within the same day only

created a day ago

Hello,

I have a scenario where I can move appointments only within the same day, so I want to allow drag and drop but I can only drop it at a different time, but not to a different date.

Is there any way I can achieve this ?

Regards

Answers approved by DevExpress Support

created 18 hours ago

Hello,

Thank you for the description.

To limit dragged appointments to the same day, you need to handle the DragAppointmentOver event, access the DragAppointments property to get the appointments being dragged, then check if they belong to the same date as their corresponding original appointments in the SourceAppointments property:

C#
private void SchedulerControl_DragAppointmentOver(object sender, DevExpress.Xpf.Scheduling.DragAppointmentOverEventArgs e) { var source = e.SourceAppointments.ToArray(); var dragged = e.DragAppointments.ToArray(); for (int i = 0; i < dragged.Length; i++) { if (source[i].Start.Date != dragged[i].Start.Date) { e.Effects = DragDropEffects.None; break; } } }

When a user drags appointments, SchedulerControl creates new copies of those appointments, and these copies are stored in DragAppointments. You can access the original appointments through SourceAppointments. The appointments in DragAppointments directly correspond to those in SourceAppointments, so it is safe to use array iteration in this case.

Please let me know if this helps.

Regards,
Marc

    Comments (1)

      Thank you Marc, this solves my task :)

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.