How can I delete "(Any)" in Scheduler Resources?

8 posts, 0 answers
  1. yurinkomarov
    yurinkomarov avatar
    7 posts
    Member since:
    Feb 2016

    Posted 16 Feb Link to this post

    Hi!

     

    How can I delete string ("Any") in Scheduler Resources?

    This this how I add my own strings

                                for (int i = 0; i < temp.Length; i++)
                                {
                                    radDropDownList5.Items.Add(temp[i].ItemArray[3].ToString());
                                    Resource resource = new Resource();
                                    resource.Id = new EventId(i);
                                    resource.Name = temp[i].ItemArray[3].ToString();
                                    //resource.Color = colors[i];
                                    //resource.Image = this.imageList1.Images[i];
                                    MessageBox.Show(temp[i].ItemArray[3].ToString());
                                    this.radScheduler1.Resources.Add(resource);
                                }

    But I results I see this (attach screenshot)

     

    Best regards, Me!

  2. yurinkomarov
    yurinkomarov avatar
    7 posts
    Member since:
    Feb 2016

    Posted 16 Feb in reply to yurinkomarov Link to this post

    Sorry, problems with image name
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 16 Feb Link to this post

    Hello Yura,

    Thank you for writing.

    In order to achieve your goal, you should create a custom EditAppointmentDialog and override the LoadResources method where you can remove the redundant resource item:
     
    public Form1()
    {
        InitializeComponent();
     
        for (int i = 0; i < 5; i++)
        {
            Resource resource = new Resource();
            resource.Id = new EventId(i);
            resource.Name = "Resource" + i;
            this.radScheduler1.Resources.Add(resource);
        }
     
        this.radScheduler1.AppointmentEditDialogShowing += radScheduler1_AppointmentEditDialogShowing;
    }
     
    CustomEditAppointmentDialog appointmentDialog = null;
     
    private void radScheduler1_AppointmentEditDialogShowing(object sender, AppointmentEditDialogShowingEventArgs e)
    {
        if (this.appointmentDialog == null)
        {
            this.appointmentDialog = new CustomEditAppointmentDialog();
        }
        e.AppointmentEditDialog = this.appointmentDialog;
    }
     
    public class CustomEditAppointmentDialog : EditAppointmentDialog
    {
        protected override void LoadResources()
        {
            base.LoadResources();
            this.cmbResource.Items.RemoveAt(1);
        }
    }

    I hope this information helps. Should you have further questions I would be glad to help.
     
    Regards,
    Dess
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  5. yurinkomarov
    yurinkomarov avatar
    7 posts
    Member since:
    Feb 2016

    Posted 16 Feb in reply to Dess Link to this post

    It works, thanks!

     

    The next question is "How to create a rule to check for blank fields before saving? Completely rewrite function buttonOK? If so, how?"

     

    Best regards, Me!

  6. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 17 Feb Link to this post

    Hello Yura,

    Thank you for writing back. 

    When the OK button in the EditAppointmentDialog is clicked, RadScheduler performs data validation. However, if you need to introduce any additional validation you can override the ValidateInput method in the custom EditAppointmentDialog:
    public class CustomEditAppointmentDialog : EditAppointmentDialog
    {
        protected override bool ValidateInput()
        {
            bool baseResult = base.ValidateInput();
            //TODO
            return baseResult;
        }
    }

    I hope this information helps. If you have any additional questions, please let me know.

    Regards,
    Dess
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  7. yurinkomarov
    yurinkomarov avatar
    7 posts
    Member since:
    Feb 2016

    Posted 18 Feb in reply to Dess Link to this post

    Do not quite understand.

    I need this class to register in the basic form, which the scheduler is? Or in the Custom AppointmentEditForm?

    Best regards, Me!

  8. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 18 Feb Link to this post

    Hello Yura,

    Thank you for writing back. 
     
    As it was demonstrated in my initial reply, you can subscribe to the RadScheduler.AppointmentEditDialogShowing event and replace the default EditAppointmentDialog with your custom one. In the descendant of the EditAppointmentDialog, you can override the ValidateInput method and add the desired blank fields check. Thus, when the OK button is clicked and the validation is not successful, the changes will not be applied to the associated Appointment.

    In the following help article, it is demonstrated a complete example of creating a custom edit dialog: http://docs.telerik.com/devtools/winforms/scheduler/appointments-and-dialogs/adding-a-custom-field-to-the-editappointment-dialog

    I hope this information helps. If you have any additional questions, please let me know.

    Regards,
    Dess
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  9. yurinkomarov
    yurinkomarov avatar
    7 posts
    Member since:
    Feb 2016

    Posted 18 Feb in reply to Dess Link to this post

    Thanks. Everything is OK

     

    Best regards, Me!

Back to Top
UI for WinForms is Visual Studio 2017 Ready