AppointmentEditDialog - show without using context menu

7 posts, 0 answers
  1. Johan Hedlund
    Johan Hedlund avatar
    3 posts
    Member since:
    Oct 2009

    Posted 25 Jan 2010 Link to this post

    Hi,

    I wonder if it is possible to show the editappointment dialog programatically, i.e. not via the built-in context menu?

    The dialog should show based on the selection in the scheduler, i.e. the same way as the context menu command does.

    The reason why I'm asking is that I want to show the dialog through a separate toolbar command.

    Thanks in advance,
    Johan
  2. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 26 Jan 2010 Link to this post

    Hi Johan Hedlund,

    You should use the following code to show edit appointment dialog:

    Appointment app = new Appointment(savedDate, savedDate.AddMinutes(this.minutes));
    this.editDialog = new EditAppointmentDialog(app, this.radScheduler1);
    if (this.editDialog.ShowDialog(this) == DialogResult.OK)
    {
        this.radScheduler1.Appointments.Add(this.editDialog.Appointment);
    }

    In order to take the selected cell in the scheduler you should subscribe to MouseDown event on the scheduler and in it use the following code:

    SchedulerCellElement cell = this.radScheduler1.SchedulerElement.ElementTree.GetElementAtPoint(e.Location) as SchedulerCellElement;
     
    if (cell as SchedulerHeaderCellElement != null)
        return;
     
    if (cell != null)
    {
        savedDate = cell.Date;     
    }

    For more details look at the attached example.

    Sincerely yours,
    Dobry
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Johan Hedlund
    Johan Hedlund avatar
    3 posts
    Member since:
    Oct 2009

    Posted 28 Jan 2010 Link to this post

    Thank you Dobry.

    If I want to disable the default response to the double-click event, i.e. NOT show the appointment form, is it just to set the appointmentdialog to null in the OnAppointmenDialogShowing event or is it any "cleaner" solution to this?

    Regards,
    Johan
  5. Dobry Zranchev
    Admin
    Dobry Zranchev avatar
    348 posts

    Posted 29 Jan 2010 Link to this post

    Hi Johan Hedlund,

    Yes this is the right solution to block the showing of EditAppointmentDialog. But this will block all showings of this dialog. If you want to block it only upon DoubleClick you should subscribe to DoubleClick event and rise the some flag. Look the code below:

    private bool isDoubleClick;
    private void radScheduler1_AppointmentEditDialogShowing(object sender, AppointmentEditDialogShowingEventArgs e)
    {
        if (isDoubleClick)
        {
            e.AppointmentEditDialog = null;
            isDoubleClick = false;
        }
    }
    private void radScheduler1_DoubleClick(object sender, EventArgs e)
    {
        isDoubleClick = true;
    }

    Feel free to ask additional questions.

    Kind regards,
    Dobry
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Richard
    Richard avatar
    32 posts
    Member since:
    Aug 2010

    Posted 11 Sep 2011 Link to this post


    Hi,

    I am posting my question here as I believe it is logically related to this thread.

    What I want to do is show the Edit Appointment Dialog when an appointment in the scheduler is double clicked. However I do not want to show the Edit Appointment Dialog when a free time slot is double clicked.

    Is there any way this could be done?

    The main obstacle seems to be that I am unable to detect whether the DoubleClick was on an empty time slot or on an appointment.

    Thanks,
  7. Richard
    Richard avatar
    32 posts
    Member since:
    Aug 2010

    Posted 12 Sep 2011 Link to this post

    OK, I think I figured this out..
    Hope this is a good way of differentiating whether the double click was on an appointment cell or not.
    Private DisableDoubleClick As Boolean = False
     
        Private Sub radScheduler1_DoubleClick(sender As Object, e As System.EventArgs) Handles radScheduler1.DoubleClick
            Dim point As Point = Me.radScheduler1.PointToClient(Cursor.Position)
            Dim schedulerCell As SchedulerCellElement = TryCast(Me.radScheduler1.ElementTree.GetElementAtPoint(point), SchedulerCellElement)
     
            If schedulerCell IsNot Nothing Then
                DisableDoubleClick = True
            End If
        End Sub
     
        Private Sub radScheduler1_AppointmentEditDialogShowing(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.AppointmentEditDialogShowingEventArgs) Handles radScheduler1.AppointmentEditDialogShowing
            If DisableDoubleClick Then
                e.Cancel = True
                e.AppointmentEditDialog = Nothing
                DisableDoubleClick = False
            Else
                e.AppointmentEditDialog = New CustomEditAppointmentDialog()
            End If
     
        End Sub

    Regards,

  8. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 14 Sep 2011 Link to this post

    Hi Richard,

    I am writing to confirm that this is the correct approach. I am glad that you have managed to figure it out.

    Should you have any further questions, do not hesitate to contact us.

    Regards,
    Ivan Todorov
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Back to Top
UI for WinForms is Visual Studio 2017 Ready