c#在foreach循环中隐藏tabpages

c# Hide tabpages in foreach loop

我想隐藏选项卡控件中的所有页面(1 除外),但我的明显猜测不起作用,我找不到其他任何东西。

我试试:

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?)

您必须删除页面才能将其隐藏,然后重新添加才能使其再次可见。请参阅 How to hide TabPage from TabControl