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
  • 148,824
  • 21
  • 237
  • 306
Davide Andrea
  • 1,267
  • 1
  • 13
  • 36

1 Answers1

2

Try to cast the Tabpage.Parent to a TabControl:

TabControl parent = tabpage.Parent as TabControl;
Patrick Hofman
  • 148,824
  • 21
  • 237
  • 306
  • 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