making resource a mandatory field

4 posts, 0 answers
  1. Kerry
    Kerry avatar
    61 posts
    Member since:
    Nov 2008

    Posted 15 Oct 2013 Link to this post

    Hello,

    I read of someone removing the (none) and (any) options from the resources dropdown on the AppointmentEdit form, what I like is to keep (none) and if the user does not select a resource other than (none) prompt the user to select a valid resource.  I was trying the ApplySettingsToEvent method and it does not look to be firing when I close the Apppointment edit form.  Using VS2008 RadScheduler 2012.1.321.20 .

    Thanks
  2. George
    Admin
    George avatar
    500 posts

    Posted 17 Oct 2013 Link to this post

    Hi Kerry,

    Thank you for contacting us.

    In your case the best choice seems to be to create a custom EditAppointmentDialog:
    public class MyEditAppointmentDialog : EditAppointmentDialog
    {
        private bool canceled;
     
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
     
            this.buttonCancel.MouseDown += ButtonCancel_MouseDown;
        }
     
        void ButtonCancel_MouseDown(object sender, MouseEventArgs e)
        {
            canceled = true;
        }
     
        protected override void OnClosing(CancelEventArgs e)
        {
            base.OnClosing(e);
            if (this.cmbResource.SelectedItem.Text == "None" && !canceled)
            {
                e.Cancel = true;
                MessageBox.Show("Select a different value");
            }
     
            canceled = false;
        }
    }

    You can use it in the AppointmentEditDialogShowing event of RadScheduler:
    void scheduler_AppointmentEditDialogShowing(object sender, AppointmentEditDialogShowingEventArgs e)
    {
        e.AppointmentEditDialog = new MyEditAppointmentDialog();
    }

    With this dialog whenever one tries to leave the form with a selected resource "None" he will not be able to, unless the cancel button is pressed.

    I hope this helps.

    Regards,
    George
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Vijay
    Vijay avatar
    4 posts
    Member since:
    Sep 2013

    Posted 29 Oct 2013 Link to this post

    PLEASE IGNORE MY POST BELOW. NOT SURE WHAT CHANGED BUT IS WORKING. THANKS.

    I used the code you have provided below to check if a control in my appointment dialogue is populated or not. If it is not I cancel the closing using e.Cancel in the OnClosing event function.

    However, I have found the following. Once the event is cancelled, the OnClosing event does not fire subsequently (fires once only) if the Cancel button is selected. When I say does not fire, it does not even reach the break point I have placed in the beginning of the OnClosing function.

    Please help.

    Thanks,
    Vijay
  5. George
    Admin
    George avatar
    500 posts

    Posted 01 Nov 2013 Link to this post

    Hello Vijay,

    I am glad that you resolved your issue.

    Let me know if I can be of further assistance.

    Regards,
    George
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top