Read Only appointments

2 posts, 1 answers
  1. AMF
    AMF avatar
    34 posts
    Member since:
    Mar 2011

    Posted 10 Jan 2012 Link to this post

    Hi all,

    Is there a way to show the appointment edit dialog in read-only when an appointment has the property AllowEdit set to false, instead of not showing the edit dialog at all.

    The problem is that it isn't possible to see all the information of the appointment.

    Greetings
  2. Answer
    Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 12 Jan 2012 Link to this post

    Hello,

    Yes, there is a way to achieve this. To do so, you need to override a single method of RadScheduler and show a custom dialog when editing read-only appointments. The approach is demonstrated below:
    public class MyScheduler : RadScheduler
    {
        public override DialogResult ShowAppointmentEditDialog(IEvent appointment, bool recurringAppointment)
        {
            if (appointment == null)
                return DialogResult.Cancel;
     
            if (!appointment.AllowEdit)
            {
                IEditAppointmentDialog dialog = this.CreateReadOnlyDialog();
                IComponentTreeHandler radComponent = dialog as IComponentTreeHandler;
     
                if (radComponent != null)
                    radComponent.ThemeName = this.ThemeName;
     
                if (!dialog.EditAppointment(appointment, this))
                    return DialogResult.Cancel;
     
                return dialog.ShowDialog();
            }
            else
            {
                return base.ShowAppointmentEditDialog(appointment, recurringAppointment);
            }
        }
     
        private IEditAppointmentDialog CreateReadOnlyDialog()
        {
            return new ReadOnlyEditAppointmentDialog();
        }
     
        public override string ThemeClassName
        {
            get
            {
                return typeof(RadScheduler).FullName;
            }
            set
            {
                base.ThemeClassName = value;
            }
        }
    }
     
    public class ReadOnlyEditAppointmentDialog : EditAppointmentDialog
    {
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            this.txtSubject.ReadOnly = true;
            this.txtLocation.ReadOnly = true;
            this.textBoxDescription.ReadOnly = true;
            this.cmbBackground.Enabled = false;
            this.cmbShowTimeAs.Enabled = false;
            this.cmbResource.Enabled = false;
            this.timeStart.Enabled = this.timeEnd.Enabled = false;
            this.dateStart.Enabled = this.dateEnd.Enabled = false;
            this.chkAllDay.Enabled = false;
     
            this.buttonCancel.Visible = this.buttonDelete.Visible =
                this.buttonRecurrence.Visible = false;
        }
     
        protected override void ApplySettingsToEvent(IEvent targetEvent)
        {
              
        }
    }

    I hope you find this useful. Do not hesitate to ask if you have any further questions.

    Regards,
    Ivan Todorov
    the Telerik team

    SP1 of Q3’11 of RadControls for WinForms is available for download (see what's new).

  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top