Dynamicalliy create RadTabStrip control

6 posts, 0 answers
  1. Lorenzo
    Lorenzo avatar
    17 posts
    Member since:
    Aug 2007

    Posted 16 Oct 2007 Link to this post

    Hi,

    I have to dynamically create a RadTabStrip control inside form (form MDI application).
    I used this code:
    -------------------------------------------------------------------
    Telerik.WinControls.UI.RadTabStrip radTabStrip = new Telerik.WinControls.UI.RadTabStrip();

    radTabStrip.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(191)))), ((int)(((byte)(219)))), ((int)(((byte)(254)))));
    radTabStrip.Dock = DockStyle.Fill;

    Telerik.WinControls.UI.TabItem t1 = new Telerik.WinControls.UI.TabItem("Tab 1");
    Telerik.WinControls.UI.TabItem t2 = new Telerik.WinControls.UI.TabItem("Tab 2");
    Telerik.WinControls.UI.TabItem t3 = new Telerik.WinControls.UI.TabItem("Tab 3");

    radTabStrip.Items.AddRange(new Telerik.WinControls.RadItem[] { t1, t2, t3 });

    t1.ContentPanel.BackColor = System.Drawing.Color.Transparent;
    t2.ContentPanel.BackColor = System.Drawing.Color.Transparent;
    t3.ContentPanel.BackColor = System.Drawing.Color.Transparent;

    Button b1, b2, b3;
    b1 = new Button(); b2 = new Button(); b3 = new Button();
    b1.Text = "Bottone 1"; b2.Text = "Bottone 2"; b3.Text = "Bottone 3";
    t1.ContentPanel.Controls.Add(b1);
    t2.ContentPanel.Controls.Add(b2);
    t3.ContentPanel.Controls.Add(b3);

    radTabStrip.TabsPosition = Telerik.WinControls.UI.TabPositions.Bottom;

    this.Controls.Add(radTabStrip);
    -------------------------------------------------------------------
    This code works, but the control isn't displayed fine! In particular tab buttons are not displayed as they are displayed when i use designer to create RadTabStrip.

    What is the best way to solve my problem?
    Thank you very much for support.

    Lorenzo

  2. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 16 Oct 2007 Link to this post

    Hello Lorenzo,

    Could you provide more detail on the tab buttons not visible?

    I've tested your code and it works fine. I've only noticed that the theme is not applied. Could you try to place the following code before you call the Add method of the controls collection:

    radTabStrip.BeginInit();
    radTabStrip.EndInit();

    I hope this helps. Please contact us again, if we could be of further assistance.

    Greetings,
    Boyko Markov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Lorenzo
    Lorenzo avatar
    17 posts
    Member since:
    Aug 2007

    Posted 16 Oct 2007 Link to this post

    Yes, it's right. With my code the tab buttons are visible, but the theme is not applied.

    Your solution works fine!
    Thank you very much for support and for fast response!

    Lorenzo
  5. Boyko Markov
    Admin
    Boyko Markov avatar
    610 posts

    Posted 16 Oct 2007 Link to this post

    Hi Lorenzo,

    I'm glad I was able to help you with this issue.
    If you need any additional help, please do not hesitate to contact me. 

    Regards,
    Boyko Markov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Jim Miles
    Jim Miles avatar
    22 posts
    Member since:
    May 2006

    Posted 29 Oct 2008 Link to this post

    Hi,

    Just want to recommend adding a dynamic tab with dynamic controls sample to the tabStrip documentation that actually adds controls to the tab strip dynamically.  This post is the only code I found that gave me a clue.  All the included samples only manipulate the tabStrip tabs, but do not show how to access the content panel to manipulate controls.

    -Jim
  7. Nick
    Admin
    Nick avatar
    767 posts

    Posted 30 Oct 2008 Link to this post

    Hello Jim Miles,

    Thank you for your feedback. We will add such topics in our documentation.

    Do not hesitate to contact me back if you have more suggestions.
     

    Greetings,
    Nick
    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