This is a migrated thread and some comments may be shown as answers.

Read Only appointments

1 Answer 92 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
AMF
Top achievements
Rank 2
AMF asked on 10 Jan 2012, 09:00 AM
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

1 Answer, 1 is accepted

Sort by
0
Accepted
Ivan Todorov
Telerik team
answered on 12 Jan 2012, 10:09 AM
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).

Tags
Scheduler and Reminder
Asked by
AMF
Top achievements
Rank 2
Answers by
Ivan Todorov
Telerik team
Share this question
or