1

I have an instance of a TabPage.

I want to ask that TabPage:

"Who's your TabControl?"

That is, I wish to query a TabPage to get a reference to the TabControl that contains it.

Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
Davide Andrea
  • 1,357
  • 2
  • 15
  • 39

1 Answers1

2

Try to cast the Tabpage.Parent to a TabControl:

TabControl parent = tabpage.Parent as TabControl;
Patrick Hofman
  • 153,850
  • 22
  • 249
  • 325
  • 2
    Thanks. Except that I would prefer (TabControl)tabpage.Parent (Ref: http://stackoverflow.com/questions/132445/direct-casting-vs-as-operator) – Davide Andrea Nov 28 '14 at 19:32