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]

explanation can be in any language....
 
P

Phillip Ross Taylor

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]

explanation can be in any language....

'get the control off the current tab

Dim controlRef As Control =
TabControl1.SelectedTab.Controls(0) '<- 0 because it's first and only
control on tab

'make it useful by converting from a control into the
WebBrowser control

Dim webControl As WebBrowser = DirectCast(controlRef,
WebBrowser)

'do what you want.
webControl.Navigate(txtAddress.Text)
 
S

sravan_reddy001

i got this in VB. but how it will work in C#

is there any equivalent conversion in C#??

Sravan Reddy
 

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