Getting the reference to the control add to a TabControl

S

sravan_reddy001

I created a tabcontrol toolin my application.(actually i am creating a
tabbed browser)

when the user clicks on the newtab button(provided by me) the new tab
is added and the webbrowser control is added to that by the following
code.

TabPage t = new TabPage();
t.Text = "tabpage" + i.ToString();
tabControl1.TabPages.Add(t);
WebBrowser w = new WebBrowser();
t.Controls.Add(w);
w.Dock = DockStyle.Fill;

now depeding the current tab selected i want the reference to the
tabpage and the webbrowser control added to that.

index1 = tabControl1.TabIndex;
t1 = tabControl1.TabPages[index1];
now how can get reference to the webcontrol added to t1;

i need the code for this : w1=[the reference to the
webcontrol in t1]


---Sravan
 
?

=?iso-8859-1?q?Horacio_Nu=F1ez_Hern=E1ndez?=

I created a tabcontrol toolin my application.(actually i am creating a
tabbed browser)

when the user clicks on the newtab button(provided by me) the new tab
is added and the webbrowser control is added to that by the following
code.

TabPage t = new TabPage();
t.Text = "tabpage" + i.ToString();
tabControl1.TabPages.Add(t);
WebBrowser w = new WebBrowser();
t.Controls.Add(w);
w.Dock = DockStyle.Fill;

now depeding the current tab selected i want the reference to the
tabpage and the webbrowser control added to that.

index1 = tabControl1.TabIndex;
t1 = tabControl1.TabPages[index1];
now how can get reference to the webcontrol added to t1;

i need the code for this : w1=[the reference to the
webcontrol in t1]

---Sravan


Hi,

You see the tabindex is about the tab order to switch between control
using the tab key, so you must use something like selectedindex or use
the selectedtab (i dont remember the property name but is something
like that) to get the selection then use controls[0] and you will get
your browser

cheers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top