Code:
private void button1_Click(object sender, EventArgs e)
{
string title = "Round " + (tabControl1.TabCount + 1).ToString();
TabPage myTabPage = new TabPage(title);
tabControl1.TabPages.Add(myTabPage);
tabControl1.SelectedIndex = tabControl1.TabCount;
textBox9.Parent = tabControl1.TabPages[tabControl1.SelectedIndex];
label9.Parent = tabControl1.TabPages[tabControl1.SelectedIndex];
}
I can't understand why you are setting the SelectedIndex just to use it's value later on though here. Why not just use tabControl1.TabCount if that's the value you know you'll be using later on? SelectedIndex has other purposes.
If you're just setting the parent to a specific TextBox though then you're not duplicating anything. Same thing with that Label. Although pionting that out, this won't work anyways unless you use tabControl1.TabCount - 1, becuase the indexing is 0 based...
Example:
Code:
string title = "Round " + (tabControl1.TabCount + 1).ToString();
TabPage myTabPage = new TabPage(title);
tabControl1.TabPages.Add(myTabPage);
TextBox T = new TextBox()
{
Text = textBox1.Text,
Size = textBox1.Size
};
tabControl1.TabPages[tabControl1.TabCount - 1].Controls.Add(T);
*Set other properties for the new TextBox accordingly if you want to change the position or anything else... You can do it this way because each TabPage is a container for controls, so it has a Controls.Add() method.