-1

So I am making a small Program where I have a UserControl inside a tab control. And i am trying to find out how to go back up a level from inside the user control to add tabs to the tab control.

Lazurus
  • 67
  • 1
  • 8

1 Answers1

-1

Okay Thanks for the comment, I figured it out, the link posted by CarbineCoder had the following code

Form parentForm = (this.Parent as Form);

This is the code i was trying to use but what was actually needed was

Form parentForm = (this.Parent.Parent as Form);
Lazurus
  • 67
  • 1
  • 8
  • Well, that makes no sense. The Parent of the user control is the TabPage. The parent of the tab page is the TabControl. That's not a Form. Don't do this at all, it is wrong. – Hans Passant Mar 21 '16 at 00:50
  • I wanted the TabControl though? I was aiming to get the TabControl – Lazurus Mar 21 '16 at 00:51