Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Parent" Method and TabPages/TabControls

Status
Not open for further replies.

bppj

Programmer
Jun 6, 2002
24
US
Hello... I'm a relative newbie to vb.net, OOP, and programming in general. (I accidently hit the "programmer" selection when setting up my account... can't say the adjective really applies... unless you count my Fortran 77 training 10+ years ago.[wink])

I have a TabPage with a button. The call on the button click is supposed to add another TabPage to the current TabPage's parent TabControl. I then want to make the new TabPage the "selected" page. I was hoping I could use:
Code:
  Dim newPage As TabPage = new TabPage()
  me.Parent.Controls.Add(newPage)
  me.Parent.SelectedTab = newPage
Problem is, the compiler says that the "SelectedTab" method does not exist for "System.Windows.Forms.Control"...
I guess this makes sense, as the method "Parent" returns a control. Funny thing is, if a do a
Code:
  MessageBox.Show(me.Parent.GetType.ToString)
I get: "System.Windows.Forms.TabControl"

Which also makes sense. Anyway, I have written a workaround by passing the tabcontrol reference around, but it seems very inelligent to me. Besides, it is obvious I am missing a concept here.

Can anyone help?

Thank you!






 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top