Christopher
Posted
on Aug 21, 2008
(permalink)
I an creating a custom date picker control using the radCalendar. (The radDatetime picker does not allow for some of the calendar options our client has requested).
The user control uses a ToolStripDropDown to display the radCalendar control when the user clicks a button.
My problem is the theme is not applied from the second through xth instance of the user control. The first instance added to a form will always theme correctly.
Below is a snippet of code from the user control showing the creation of the radCalendar, ToolStripControlHost and ToolStripDropdown control.
Suggestions?
Thanks,
Chris
| //Create the calendar |
| RadCalendar radCalendar = new RadCalendar(); |
| radCalendar.Orientation = Orientation.Horizontal; |
| radCalendar.DayNameFormat = Telerik.WinControls.UI.DayNameFormat.Full; |
| radCalendar.ShowRowHeaders = false; |
| radCalendar.ShowColumnHeaders = true; |
| radCalendar.AllowMultipleView = true; |
| radCalendar.MultiViewColumns = 2; |
| radCalendar.ThemeName = "Office2007Blue"; |
| radCalendar.Size = new Size(462, 275); |
| radCalendar.SelectionChanged += new EventHandler(radCalendar_SelectionChanged); |
| |
| //Create the Calendar Host |
| _calendarHost = new ToolStripControlHost(radCalendar); |
| _calendarHost.Height = radCalendar.Height; |
| _calendarHost.Width = radCalendar.Width; |
| |
| //Create the drop down |
| _dropDown = new ToolStripDropDown(); |
| _dropDown.Width = radCalendar.Width; |
| _dropDown.Height = radCalendar.HeaderHeight; |
| _dropDown.VisibleChanged += new EventHandler(_dropDown_VisibleChanged); |
| _dropDown.Items.Add(_calendarHost); |
Reply
Christopher
Posted
on Aug 21, 2008
(permalink)
I was able to correct this issue by setting the ThemeClassName property and ensuring they were the last properties set on the control.
The code now looks like:
| //Create the calendar |
| RadCalendar radCalendar = new RadCalendar(); |
| radCalendar.Orientation = Orientation.Horizontal; |
| radCalendar.DayNameFormat = Telerik.WinControls.UI.DayNameFormat.Full; |
| radCalendar.ShowRowHeaders = false; |
| radCalendar.ShowColumnHeaders = true; |
| radCalendar.AllowMultipleView = true; |
| radCalendar.MultiViewColumns = 2; |
| radCalendar.Size = new Size(462, 275); |
| radCalendar.ThemeName = "Office2007Blue"; |
| radCalendar.ThemeClassName = "Telerik.WinControls.UI.RadCalendar"; |
| radCalendar.SelectionChanged += new EventHandler(radCalendar_SelectionChanged); |
Thanks,
Chris
Reply
Answer
Mike
Mike
Posted
on Aug 21, 2008
(permalink)
Hi Christopher,
For performance reasons we suspend theme applying, until RadControl's EndInit() method is invoked. Generally this is done automatically by the control designer, but in your case (when adding the control dynamicaly to the form) you can just call
radCalendar.BeginInit();
radCalendar.EndInit(); when setting up the control. It is not necessary to set
ThemeClassName property.
Sincerely yours,
Mike
the Telerik team
Check out
Telerik Trainer, the state of the art learning tool for Telerik products.
Reply
Christopher
Posted
on Aug 21, 2008
(permalink)
Thanks Mike!
Are there any cons to setting the ThemeClassName property in this context?
Given the reason for the theme not applying in this case, I'm also a bit confused as to why setting the ThemeClassName and reordering the property sets would have solved the issue as well.
Chris
Reply
Mike
Mike
Posted
on Aug 22, 2008
(permalink)
Hi Christopher,
ThemeClassName property is used by the ThemeResolutionService as a key to identify what StyleSheet the control should obtain during the theme resolution process - triggered initially by EndIni(). Setting the ThemeClassName property would not trigger theme refresh. ThemeClassName defaults to the control type's full name. Changing ThemeName on the other hand, would trigger refresh of the theme and this was most probably why the issue was resolved by reordering your lines of code.
Best wishes,
Mike
the Telerik team
Check out
Telerik Trainer, the state of the art learning tool for Telerik products.
Reply