0

I want to hide all pages in a tab control (except 1), but my obvious guess does not work and I can't find anything else.

I try:

foreach (TabPage page in myTabControl.TabPages)
    {
        ...
        page.PageVisible = false;    //Compile error here
    }

'System.Windows.Forms.TabPage' does not contain a definition for 'PageVisible' and no extension method 'PageVisible' accepting a first argument of type 'System.Windows.Forms.TabPage' could be found (are you missing a using directive or an assembly reference?)

Cameron Castillo
  • 2,712
  • 10
  • 47
  • 77
  • You have to remove it from the tab pages collection, Tab pages don't have a visibility property as you found out. – Ron Beyer Jun 01 '15 at 14:21
  • This answers your question: http://stackoverflow.com/questions/552579/how-to-hide-tabpage-from-tabcontrol – Tim Schmelter Jun 01 '15 at 14:21
  • Read the [documentaion](https://msdn.microsoft.com/en-us/library/y6e1ah1k(v=vs.110).aspx) for `TabPage.Visible`. It states _"To hide a tab in a TabControl, you must remove it from the control's TabPages collection."_ – juharr Jun 01 '15 at 14:27

1 Answers1

1

You have to remove the page to hide it and re-add it to make it visible once more. Please see How to hide TabPage from TabControl

Community
  • 1
  • 1
David Arno
  • 42,717
  • 16
  • 86
  • 131