radCalendar Theme issue

5 posts, 1 answers
  1. Christopher
    Christopher avatar
    30 posts
    Member since:
    Jul 2008

    Posted 21 Aug 2008 Link to this post

    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); 

  2. Christopher
    Christopher avatar
    30 posts
    Member since:
    Jul 2008

    Posted 21 Aug 2008 Link to this post

    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
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Answer
    Mike
    Admin
    Mike avatar
    640 posts

    Posted 21 Aug 2008 Link to this post

    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.
  5. Christopher
    Christopher avatar
    30 posts
    Member since:
    Jul 2008

    Posted 21 Aug 2008 Link to this post

    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
  6. Mike
    Admin
    Mike avatar
    640 posts

    Posted 22 Aug 2008 Link to this post

    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.
Back to Top
UI for WinForms is Visual Studio 2017 Ready