Getting the reference to the control add to a TabControl

  • Thread starter Thread starter sravan_reddy001
  • Start date Start date
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....
 
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)
 
i got this in VB. but how it will work in C#

is there any equivalent conversion in C#??

Sravan Reddy
 
Back
Top