i have created a usercontrol, then i have a tabcontrol where in there is a tabpage that contains a 2 buttons, when button1 is clicked, it creates a new tabpage and the user control is added to its controls through
tab = new TabPage();
UserControl1 uc = new UserControl1();
tab.Controls.Add(uc);
tab.Name = "0";
tab.Text = tab.Name;
tabControl1.TabPages.Add(tab);
now when i click the button2, it should put text in the textbox inside the usercontrol-tabpage that was just created, i implemented it with this code,
TextBox sel = (TextBox)tabControl1.TabPages["0"].Controls["textBox1"];
sel.Text = "ssss";
but it returns a runtime error, saying that it cannot find the said control, so i tried
TextBox sel = (TextBox)tabControl1.TabPages["0"].Controls[0];
sel.Text = "ssss";
but it still returns a runtime error, saying that the cast usercontrol cannot be applied to textbox. i dont know what that means.. pls help me in this.. i also tried putting in Controls[1] but it returned a runtime error, of which is a OutofBounds exception. i dont know what to do, or how to find the control inside the usercontrol in the tabpage... pls hellp