I programmatically create interfaces rather than use VS.net Designer, and almost all Telerik Windows Forms controls work Ok with this, however I cannot get the toolstrip to render correctly using the default application theme. If I switch default application themes having created and loaded my new toolstrip it renders correctly but until I toggle the theme it looks poor.
I try to work around this by calling the following for each control I create at runtime;
private void applyThemeToGeneratedControl(Telerik.WinControls.RadControl control)
control.ThemeName = Telerik.WinControls.
which does work for the majority of controls, but not for toolstrip.
Any ideas what I'm doing wrong here ?
5 Answers, 1 is accepted
I'm not sure what could be the problem here. I have tested locally in our Demo application. The steps in my test scenario are:
1. Drag and drop a new instance of RadButton
2. Subscribe to button click event.
3. Create a new RadToolStrip and add RadToolStripElement and RadToolStripItem to it, then modify its theme and change it to "Desert".
private void radButton2_Click(object sender, EventArgs e)
RadToolStrip toolStrip = new RadToolStrip();
toolStrip.Size = new Size(150, 30);
RadToolStripElement toolStripElement = new RadToolStripElement();
RadToolStripItem toolStripItem = new RadToolStripItem();
toolStrip.ThemeName = "Desert";
The following code worked for me. Please make sure that the Theme component is added to the component tray when you change the theme. In my case I had to drag and drop the Desert Theme component.
Please write me back if the information here has helped you. If not I will greatly appreciate if you send me a sample project demonstrating the issue and I will do my best to fix it.
the Telerik team
Thanks for the reply.
I think my problem must be a misunderstanding of the way the theme in the component tray is handled. I had assumed that if I could address a named theme through the ApplicationThemeName, that meant it was loaded correctly (I had assumed an Exception if this theme had not been loaded or could not be deserialized at the time of naming it).
I do have the named theme loaded as a component in the main application shell window, however it is not loaded in the specific container that I'm creating the tool strip into. My window structure is;
MainWindow -> has Vista Theme Component loaded
-- Tabs -> created at design time
---- Tab -> Created at runtime
------- Tool Strip -> Created at runtime. Doesn't seem to inherit the ApplicationThemeName that was set at design time.
My assumption here is that the Setter of the ApplicationThemeName walks the application control tree and resets its applies the style and thematics, which is why I'm trying to forcible apply the ApplicationThemeName to the control once I've created it. If, afer creating my Tool Strip I toggle the value of the ApplicationThemeName then everything renders fine (following the neccessary pause).
In the above structure, where would you expect to find a reference to the Theme component ? On the Form (its already there) or on some lower level control ?
The purpose of the ApplicationThemeName property is to set the theme for all the controls in your application. However, ApplicationThemeName does not load themes. The themes are loaded in your application when you drag and drop a theme component on your form. The moment during the run-time where you set ApplicationThemeName does not matter - even if you create controls after you set ApplicationThemeName, they will know about this setting and they will have the correct theme applied (if this theme is loaded).
I suppose that your issue is related to the Vista theme for RadToolStrip. Please note that in Q1 2009 RadToolStrip does not have a Vista theme in the Vista theme component. Therefore, even if you set ApplicationThemeName to Vista, you will not get the desired look. I am glad to inform you that we included Vista theme for RadToolStrip in the Vista theme component in Q1 2009 SP1 (v.2009.1.9.414). In order to update from Q1 2009 to Q1 2009 SP1, please refer to the following Knowledge Base article.
I hope this helps. If you have additional questions, feel free to contact me.
the Telerik team
Well, in most cases you do not need to call EndEdit, although there are certain places where it is obviously needed.
the Telerik team