I have a form in which I would like to be able to add tabs dynamically through the use of a button (much like the buttons most modern browsers have for adding tabs). These tabs should also contain a text box which is stretched to the individual tab's width and height upon creation.
I apologise for the lack of code but besides instantiating a TabControl container within a Form class, I have no clue as to what I should do next.
Thanks in advance.
All you need is to call the Add
method on the TabControl.TabPages
collection, then add other controls to that TabPage, like so:
private void button1_Click(object sender, EventArgs e)
{
TabPage tp = new TabPage("Test");
tabControl1.TabPages.Add(tp);
TextBox tb = new TextBox();
tb.Dock = DockStyle.Fill;
tb.Multiline = true;
tp.Controls.Add(tb);
}
Hope this helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With