Apply theme on a cell

5 posts, 1 answers
  1. Yaroslav
    Yaroslav avatar
    24 posts
    Member since:
    Nov 2011

    Posted 02 Mar 2012 Link to this post

    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!
  2. Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 06 Mar 2012 Link to this post

    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 >>
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Yaroslav
    Yaroslav avatar
    24 posts
    Member since:
    Nov 2011

    Posted 06 Mar 2012 Link to this post

    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
  5. Answer
    Ivan Petrov
    Admin
    Ivan Petrov avatar
    701 posts

    Posted 09 Mar 2012 Link to this post

    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 >>
  6. Yaroslav
    Yaroslav avatar
    24 posts
    Member since:
    Nov 2011

    Posted 09 Mar 2012 Link to this post

    Thanks for replying, already managed to modify what I needed, on code on the cellformatting event.
Back to Top
UI for WinForms is Visual Studio 2017 Ready