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

Apply theme on a cell

4 Answers 64 Views
Themes and Visual Style Builder
This is a migrated thread and some comments may be shown as answers.
Yaroslav
Top achievements
Rank 1
Yaroslav asked on 02 Mar 2012, 02:37 PM
Hi, I've a theme for all the application. Created another 2 themes that I want to apply on some cells on a gridview. Dinamically, depending of a parameter value I will apply to a cell one of the 2 themes on the cellformatting event. Is easy to say, but I can't get it done. Followed instructions on the Rad Winforms overview site regarding theme application, added a radthememanager, added my two themes but it does not work.

The themes where created on the VSB and saved as independen XML files, saving only two repositories that I need, a gradient and a shape. Is this correct? Or maybe I do need to save the full theme, nevertheless everyting else other than these 2 repository items are equal?

Thanks!

4 Answers, 1 is accepted

Sort by
0
Ivan Petrov
Telerik team
answered on 06 Mar 2012, 02:22 PM
Hi Yaroslav,

Thank you for writing.

When you have applied a theme using the ThemeResolutionService.ApplicationThemeName, the ThemeName property of all elements will be ignored - even if you set it to a valid theme, it will not be applied. The better approach in this situation is to use code in the CellFormatting event and apply the style you want.

I hope this will be useful for you. If you need further assistance do not hesitate to write back.

Kind regards,
Ivan Petrov
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
Yaroslav
Top achievements
Rank 1
answered on 06 Mar 2012, 03:29 PM
Hmmm....but then on the CellFormatting event I must programatically change the style, accesing the hierarchy of the control? No possibility of applying the shape and gradient created on the VSB and saved as a theme? If a theme cannot be applied this way then creating and using themes is not usefull as I believed.

Usually there is a theme for all the application and then there is a need to apply another "subtheme" to a button or grid or any other control on a particular case. This is, for me, a common case. If I can not apply themes dinamically to controls and must change style on the code then wich is the point of having several themes and subsequently all the time lost on creating them.

Thanks
0
Accepted
Ivan Petrov
Telerik team
answered on 09 Mar 2012, 10:42 AM
Hi Yaroslav,

Thank you for your reply.

The main reason you cannot achieve your task using themes is that themes can be applied to RadControls and not to elements. In the cell formatting event you have the cell element and this is why you have to use code. Basically what you can achieve through VSB you can achieve through code, after all the repositories you create in VSB are translated to code so they can be applied. You can again create objects to hold the settings and use them in code the same way you use repositories in VSB.

I hope this clarifies the situation. If you have further questions, I would be glad to help.

All the best,
Ivan Petrov
the Telerik team
RadControls for WinForms Q1'12 release is now live! Check out what's new or download a free trial >>
0
Yaroslav
Top achievements
Rank 1
answered on 09 Mar 2012, 11:51 AM
Thanks for replying, already managed to modify what I needed, on code on the cellformatting event.
Tags
Themes and Visual Style Builder
Asked by
Yaroslav
Top achievements
Rank 1
Answers by
Ivan Petrov
Telerik team
Yaroslav
Top achievements
Rank 1
Share this question
or