Click here to Skip to main content
15,891,793 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Heya,

I added a Tabcontrol with a (single) Tabitem with a textbox inside, into my application. Now if I would create a new tab with:

CHead.Items.Add(item);

The new tab will be empty. How do I insert other elements into this tab or apply the content from another tab into it (at runtime)?

Thanks in advance
Posted

1 solution

You need to look at the TabControl items collection for the tabitems

You can add another and set its content, e.g. if I have a tabcontrol with 1 tab page, on that tab page a button, in the click event you could;

C#
private void button1_Click(object sender, RoutedEventArgs e)
{
    TabItem newTab = new TabItem();

    newTab.Header = "Another Tab";

    newTab.Content = new TextBox();

    tabControl1.Items.Add(newTab);

}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900