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

Dynamicalliy create RadTabStrip control

5 Answers 233 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.
Lorenzo
Top achievements
Rank 1
Lorenzo asked on 16 Oct 2007, 10:40 AM

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

5 Answers, 1 is accepted

Sort by
0
Boyko Markov
Telerik team
answered on 16 Oct 2007, 11:31 AM
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
0
Lorenzo
Top achievements
Rank 1
answered on 16 Oct 2007, 01:43 PM
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
0
Boyko Markov
Telerik team
answered on 16 Oct 2007, 02:51 PM
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
0
Jim Miles
Top achievements
Rank 1
answered on 29 Oct 2008, 01:29 PM
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
0
Nick
Telerik team
answered on 30 Oct 2008, 10:14 AM
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.
Tags
Tabstrip (obsolete as of Q2 2010)
Asked by
Lorenzo
Top achievements
Rank 1
Answers by
Boyko Markov
Telerik team
Lorenzo
Top achievements
Rank 1
Jim Miles
Top achievements
Rank 1
Nick
Telerik team
Share this question
or