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

Subclassing RadTabStrip loses theme

1 Answer 59 Views
Tabstrip (obsolete as of Q2 2010)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Michael
Top achievements
Rank 2
Michael asked on 13 Apr 2009, 06:08 PM
Hello -

If I subclass RadTabStrip, I find that I lose the default theme.  Here is the code:

        public class Tabs : RadTabStrip 
        { 
        } 
 
        void Form1_Load(object sender, EventArgs e) 
        { 
            var tabs = new RadTabStrip(); 
            Controls.Add(tabs); 
            tabs.BeginInit(); 
            tabs.Dock = DockStyle.Fill; 
            tabs.Items.Add(new TabItem() { Text = "First" }); 
            tabs.Items.Add(new TabItem() { Text = "Second" }); 
            tabs.Items.Add(new TabItem() { Text = "Third" }); 
            tabs.EndInit(); 
        } 

The above works great & is themed with the default Telerik theme.  However, if I replace "new RadTabStrip()" above with "new Tabs()", the default theme is lost.  For RadElement subclasses, I was told to override ThemeEffectiveType and return the base Telerik type, which works quite nicely.  However, being a Control rather than a RadElement, RadTabStrip doesn't support this virtual method.  I'm guessing there is some other simple way for my subclass to not get in the way of the theme mechanism.

Thanks!
- Mike

1 Answer, 1 is accepted

Sort by
0
Accepted
Victor
Telerik team
answered on 14 Apr 2009, 07:09 AM
Hi Michael,

Thank you for writing. You are correct, overriding the ThemeEffectiveType property applies to RadElement, however you need ThemeClassName property for RadControl. You need to override it and return the type of RadTabStrip.

Here is a code snippet:

namespace WindowsFormsApplication5  
{  
    class Tabs : RadTabStrip  
    {  
        public override string ThemeClassName  
        {  
            get 
            {  
                return typeof(RadTabStrip).FullName;  
            }  
            set 
            {  
                base.ThemeClassName = value;  
            }  
        }  
    }  
And here is the form constructor:
namespace WindowsFormsApplication5  
{  
    public partial class Form1 : Form  
    {  
        public Form1()  
        {  
            InitializeComponent();  
            Tabs tabControl = new Tabs();  
            tabControl.Size = new Size(300, 300);  
            tabControl.Items.Add(new TabItem("Tab1"));  
            tabControl.Items.Add(new TabItem("Tab2"));  
            tabControl.Items.Add(new TabItem("Tab3"));  
            tabControl.ThemeName = "ControlDefault";  
            this.Controls.Add(tabControl);  
        }  
    }  

Please write back if you need further assistance.

Sincerely yours,
Victor
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
Tags
Tabstrip (obsolete as of Q2 2010)
Asked by
Michael
Top achievements
Rank 2
Answers by
Victor
Telerik team
Share this question
or