Hi,
I'm trying to create a customised version of the appointment dialog, which will actually combine some of the functionality of both the EditRecurrence dialog and the EditAppointment dialog.
From the EditActivity dialog all I need is the start date and subject fields along with the save and cancel buttons, and then from EditRecurrence I want a checkbox to enable recurrence functionality, which will enable the recurrence pattern and range of recurrence groups of controls in the same dialog.
What would be the best way to implement this window? I've played around with inheriting EditRecurrenceDialog (partial class frmEditAppointment : EditRecurrenceDialog) but I can't seem to hide the controls I don't want. For example when I try to hide the All Day Event checkbox the "Visible" property is greyed out in the designer/properties window and I can't change it to false.
Given these issues I get the impression I'd be best off creating a new appointment dialog entirely, how should I go about doing this? Ideally I wouldn't want to have to recreate groups of controls like the recurrence pattern or range of recurrence and instead just add/copy them in somehow.
Thanks for your help, Tom.
21 Answers, 1 is accepted
Thank you for writing.
You can inherit the EditAppointmentDialog and open the designer. When I select a specific control its Visible property is editable in the Properties window. Please refer to the attached screenshots. However, chkAllDay RadCheckBox is a little bit specific. In the EditAppointmentDialog.Load event the visibility of the RadCheckBox is set to true again. That is why in order to hide it, you should do it via code in the Load event.
An alternative solution to create a custom edit dialog is to inherit RadSchedulerDialog and implement IEditAppointmentDialog. Thus, you will be able to build the desired design and handle the whole edit operation.
I hope this information helps. Should you have further questions, I would be glad to help.
Dess
Telerik
OK, I'm beginning to think inheriting RadSchedulerDialog and implementing IEditAppointmentDialog would be the cleanest way to proceed.
Is there an easy way to add the "Recurrence Pattern" and "Range of Recurrence" group of controls to this custom dialog or will I need to code these myself?
Thanks, Tom.
Thank you for writing back.
Inheriting the basic RadSchedulerDialog class and implementing IEditAppointmentDialog interface gives you the opportunity to construct the desired look for the edit dialog. However, you should implement the whole required functionality for this dialog. I would recommend you to download our source code and have a look at the EditAppointmentDialog class. Thus, you can pay attention to the introduced implementation about recurrence functionality and follow similar approach. Simply you can show the desired recurring dialog when a certain button is clicked.
I hope this information helps. If you have any additional questions, please let me know.
Dess
Telerik
Hi Dess,
Thanks for your reply. I'm not entirely sure you understand what I'm aiming for - what I'd prefer to have is a single dialog for both appointments and recurring appointments. The bottom of this dialog would be similar to the current recurrence dialog. A checkbox would enable the recurrence related controls. Is this doable without having to build a whole new dialog and recreate all the current control groups from scratch?
Thanks, Tom.
Thank you for writing back.
Note that by default RadScheduler displays a specific dialog for manipulating recurring appointments. You are describing a custom edit dialog. Hence, it is not possible to come out of the box and you should build it according to your requirements. Feel free to use one of the suggested approaches from my previous posts. Additionally, you can have a look at the Demo application >> Scheduler >> Custom appointment dialog example which is quite useful on this topic.
If you have any additional questions, please let me know.
Dess
Telerik
I am using visual studio 2010 and Telerik UI for WinForms Q2 2015 SP1. I am using Radscheduler in my project and I localized it's labels but everytimes I want to create a recurrence appointment with monthly or yearly recurrence pattern my application crash and throw this exception :
System.ArgumentException was unhandled
Message=An item with the same key has already been added.
Source=mscorlib
StackTrace:
at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at Telerik.WinControls.UI.Scheduler.Dialogs.MonthlyRecurrenceSettings.LoadWeekDaysInCombo(RadDropDownList comboBox, ISchedulerData data)
at Telerik.WinControls.UI.Scheduler.Dialogs.MonthlyRecurrenceSettings.ShowRecurrenceRule(RecurrenceRule recurrenceRule, CultureInfo culture)
at Telerik.WinControls.UI.Scheduler.Dialogs.EditRecurrenceDialog.radioRecurrenceRule_ToggleStateChanged(Object sender, StateChangedEventArgs args)
at Telerik.WinControls.UI.RadToggleButton.OnToggleStateChanged(EventArgs e)
at Telerik.WinControls.UI.RadRadioButton.ButtonElement_ToggleStateChanged(Object sender, StateChangedEventArgs args)
at Telerik.WinControls.UI.RadToggleButtonElement.OnToggleStateChanged(StateChangedEventArgs e)
at Telerik.WinControls.UI.RadRadioButtonElement.OnToggleStateChanged(StateChangedEventArgs e)
at Telerik.WinControls.UI.RadToggleButtonElement.SetToggleStateCore(ToggleState value)
at Telerik.WinControls.UI.RadToggleButtonElement.SetToggleState(ToggleState value)
at Telerik.WinControls.UI.RadToggleButtonElement.OnToggle()
at Telerik.WinControls.UI.RadToggleButtonElement.OnClick(EventArgs e)
at Telerik.WinControls.UI.RadRadioButtonElement.OnClick(EventArgs e)
at Telerik.WinControls.RadElement.DoClick(EventArgs e)
at Telerik.WinControls.RadElement.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadElement.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadElement.DoMouseUp(MouseEventArgs e)
at Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e)
at Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at Telerik.WinControls.RadControl.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.RunDialog(Form form)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at Telerik.WinControls.UI.Scheduler.Dialogs.EditRecurrenceDialog.Telerik.WinControls.UI.Scheduler.Dialogs.IEditRecurrenceDialog.ShowDialog()
at Telerik.WinControls.UI.Scheduler.Dialogs.EditAppointmentDialog.ShowRecurrenceDialog()
at Telerik.WinControls.UI.RadScheduler.<>c__DisplayClass3.<ShowAppointmentEditDialog>b__0(Object param0, EventArgs param1)
at System.Windows.Forms.Form.OnShown(EventArgs e)
at Telerik.WinControls.UI.Scheduler.Dialogs.EditAppointmentDialog.OnShown(EventArgs e)
at System.Windows.Forms.Form.CallShownEvent()
at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at Telerik.WinControls.UI.RadFormControlBase.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.RunDialog(Form form)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at Telerik.WinControls.UI.Scheduler.Dialogs.EditAppointmentDialog.Telerik.WinControls.UI.Scheduler.Dialogs.IEditAppointmentDialog.ShowDialog()
at Telerik.WinControls.UI.RadScheduler.ShowAppointmentEditDialog(IEvent appointment, Boolean recurringAppointment)
at Telerik.WinControls.UI.RadScheduler.AddNewAppointmentWithDialog(IEvent appointment, DateTimeInterval interval, Boolean recurringAppointment, SchedulerResourceCollection resources)
at Telerik.WinControls.UI.RadScheduler.AddNewAppointmentWithDialog(DateTimeInterval interval, Boolean allDay, Boolean recurringAppointment, SchedulerResourceCollection resources)
at Telerik.WinControls.UI.SchedulerDefaultContextMenu.OnNewRecurringItemClick(Object sender, EventArgs e)
at Telerik.WinControls.RadElement.OnClick(EventArgs e)
at Telerik.WinControls.UI.RadButtonItem.OnClick(EventArgs e)
at Telerik.WinControls.UI.RadMenuItem.OnClick(EventArgs e)
at Telerik.WinControls.RadElement.DoClick(EventArgs e)
at Telerik.WinControls.RadElement.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadElement.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadItem.RaiseBubbleEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadElement.RaiseRoutedEvent(RadElement sender, RoutedEventArgs args)
at Telerik.WinControls.RadElement.DoMouseUp(MouseEventArgs e)
at Telerik.WinControls.ComponentInputBehavior.OnMouseUp(MouseEventArgs e)
at Telerik.WinControls.RadControl.OnMouseUp(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at Telerik.WinControls.RadControl.WndProc(Message& m)
at Telerik.WinControls.UI.RadPopupControlBase.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at dentist.Program.Main() in C:\Users\Aref\Documents\Visual Studio 2010\Projects\dentist\dentist\Program.cs:line 21
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
Thank you for writing.
The provided information is not enough for me to replicate the issue locally. Could you please specify the exact steps/code snippet how to reproduce the problem? Feel free to open a support ticket and provide a sample project so we can investigate the precise case and assist you further. Thank you in advance.
I am looking forward to your reply.
Regards,
Dess
Telerik
I resolved the problem, I was using a same label for 2 cases in my Radscheduler localization provider thanks for your time.
Sincerely yours
Aref
Dear Dess
Is it possible to change recurrence form font? I need to change font and I have tried to inherit recurrence form but it did not work for me. I am looking forward to hear from you.
Sincerely yours
Aref
Thank you for writing back.
In order to change the font for the RecurrenceEditDialog, you can subscribe to the RadScheduler.RecurrenceEditDialogShowing event, iterate all the controls in the RecurrenceEditDialog and apply the desired font:
private
void
radScheduler1_RecurrenceEditDialogShowing(
object
sender, RecurrenceEditDialogShowingEventArgs e)
{
RadForm f = e.RecurrenceEditDialog
as
RadForm;
f.Font = font;
foreach
(Control c
in
f.Controls)
{
c.Font = font;
}
}
Note that this is just a sample approach and it may not cover all possible cases. It would be necessary to iterate the controls recursively in case you need to apply the font to controls from all levels. Feel free to modify it in a way which suits your requirement best.
I hope this information helps. If you have any additional questions, please let me know.
Regards,
Dess
Telerik
Dear Dess
Thanks for your post, I have already done this but some controls font's like groupbox header text and checkbox text and radiobutton text did not change. Can you please help me with this problem.
Sincerely yours
Aref
I assume that's because they are children of container controls e.g. RadGroupBox contains other controls like buttons, check boxes, etc. To handle this case you can use the ControlHelper.GetChildControls method to get all controls recursively.
I would even advice to inherit from the EditRecurrenceDialog and introduce the needed modifications there. This will be cleaner solution and will allow for further extension. Here is how this class can look like:
class
MyEditRecurrenceDialog : EditRecurrenceDialog
{
private
MyEditRecurrenceDialog()
:
base
(
null
)
{ }
public
MyEditRecurrenceDialog(IEvent appointment)
:
base
(appointment,
null
)
{
}
public
MyEditRecurrenceDialog(IEvent appointment, ISchedulerData schedulerData)
:
base
(appointment, schedulerData)
{ }
protected
override
void
OnLoad(EventArgs e)
{
base
.OnLoad(e);
SetFontForControls(
this
);
}
private
void
SetFontForControls(Control parentControl)
{
System.Drawing.Font font =
new
System.Drawing.Font(
"Consolas"
, 7);
List<Control> allControls = ControlHelper.GetChildControls<Control>(parentControl,
true
);
foreach
(Control c
in
allControls)
{
c.Font = font;
}
}
protected
override
void
ShowRecurrenceSettingsControl(IRecurrenceRuleSettingsControl settingsControl)
{
base
.ShowRecurrenceSettingsControl(settingsControl);
SetFontForControls((Control)settingsControl);
}
}
The override of the ShowRecurrenceSettingsControl method is needed, as some of the controls for the recurrence are created dynamically.
To replace the default dialog with the newly created one, you can use the RecurrenceEditDialogShowing handler, you are already familiar with:
void
radScheduler1_RecurrenceEditDialogShowing(
object
sender, RecurrenceEditDialogShowingEventArgs e)
{
e.RecurrenceEditDialog =
new
MyEditRecurrenceDialog(e.Appointment);
}
I hope that you find this information useful.
Regards,
Stefan
Telerik
Thanks for your post. It helped a lot but is there any way to change RadGroupBox headers for this form ? They did not changed with this code. I will appreciate your help.
Sincerely yours
Aref
The headers font is changed on my end with this code. See attached image.
Should you still experience this issue, please send a small sample replicating it and I will look into it.
Regards,
Stefan
Telerik
I am not sure why you are observing this behavior. What I can offer is to also set the parentControl.Font in the SetFontForControls method:
private
void
SetFontForControls(Control parentControl)
{
System.Drawing.Font font =
new
System.Drawing.Font(
"Consolas"
, 7);
parentControl.Font = font;
List<Control> allControls = ControlHelper.GetChildControls<Control>(parentControl,
true
);
foreach
(Control c
in
allControls)
{
c.Font = font;
}
}
If this does not work for you, please open a support ticket where you can attach your project so we can investigate the precise behavior.
Regards,
Stefan
Telerik
Thanks for your efforts.
Sincerely yours
Aref
When you try editing a recurring appointment you will obtain a popup offering you to choose what to edit: the whole series or the single occurrence. The, the EditAppointmentDialog is shown. The RecurrenceEditDialogShowing event is fired before the EditRecurrenceDialog is shown. This is the appropriate place to replace the default dialog with your custom one by setting the RecurrenceEditDialogShowingEventArgs.Dialog.
I have prepared a sample code snippet for your reference demonstrating how to add a custom menu item and show the custom EditRecurrenceDialog when you right-click an appointment:
private
void
radScheduler1_ContextMenuOpening(
object
sender, SchedulerContextMenuOpeningEventArgs e)
{
if
(e.Element
is
AppointmentElement)
{
RadMenuItem item =
new
RadMenuItem();
item.Text =
"Edit Recurrence"
;
item.Tag = e.Element;
item.Click += item_Click;
e.Menu.Items.Add(item);
}
}
private
void
item_Click(
object
sender, EventArgs e)
{
RadMenuItem item = sender
as
RadMenuItem;
AppointmentElement a = item.Tag
as
AppointmentElement;
CustomEditRecurrenceDialog dialog =
new
CustomEditRecurrenceDialog(a.Appointment.MasterEvent);
dialog.Show();
}
CustomEditRecurrenceDialog customRecurrenceDialog =
null
;
private
void
radScheduler1_RecurrenceEditDialogShowing(
object
sender, RecurrenceEditDialogShowingEventArgs e)
{
if
(customRecurrenceDialog !=
null
)
{
customRecurrenceDialog =
new
CustomEditRecurrenceDialog(e.Appointment);
}
e.RecurrenceEditDialog = customRecurrenceDialog;
}
I hope this information helps. If you need any further assistance please don't hesitate to contact me.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik
Hi Dess,
Is it possible to add a new appointment from the edit appointment dialogue? I am trying to create new appointments for each day of the week. I have added the property day of the week to the appointment class. I added check boxes for each day of the week to a custom edit dialogue. I would like to create a new appointment for the day that was clicked. What is the best way to go about that?
In order to add appointments programmatically, you can use the approach demonstrated in the online documentation: https://docs.telerik.com/devtools/winforms/controls/scheduler/appointments-and-dialogs/working-with-appointments
The EditAppointmentDialog allows you either to create a new appointment or edit an existing one. Please refer to the following help article which also demonstrates how to create a custom EditAppointmentDialog: https://docs.telerik.com/devtools/winforms/controls/scheduler/dialogs/editappointmentdialog
I hope this information helps.
Regards,
Dess | Tech Support Engineer, Sr.
Progress Telerik