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

radCalendar Theme issue

4 Answers 101 Views
Calendar, DateTimePicker, TimePicker and Clock
This is a migrated thread and some comments may be shown as answers.
Christopher
Top achievements
Rank 1
Christopher asked on 21 Aug 2008, 04:02 PM
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); 

4 Answers, 1 is accepted

Sort by
0
Christopher
Top achievements
Rank 1
answered on 21 Aug 2008, 04:21 PM
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
0
Accepted
Mike
Telerik team
answered on 21 Aug 2008, 04:35 PM
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.
0
Christopher
Top achievements
Rank 1
answered on 21 Aug 2008, 05:15 PM
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
0
Mike
Telerik team
answered on 22 Aug 2008, 04:43 PM
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.
Tags
Calendar, DateTimePicker, TimePicker and Clock
Asked by
Christopher
Top achievements
Rank 1
Answers by
Christopher
Top achievements
Rank 1
Mike
Telerik team
Share this question
or