[dba-VB] .NET WinForms: Hiding TabControl's TabPage

Salakhetdinov Shamil mcp2004 at mail.ru
Tue Feb 21 11:49:08 CST 2012


Hi All --

It happens that TabPage doesn't have Visible property - the solution is to  Remove/Add(Insert) TabPage on runtime and have all TabPages designed as visible on design time (if you do not want to create all the controls dynamically on run-time).
e.g: http://stackoverflow.com/questions/552579/how-to-hide-tabpage-from-tabcontrol

What isn't not written anywhere (at least I haven't found) is that when you need to simulate hiding/displaying/... of a TabPage which isn't the last one then you'd better first Insert new TabPage and then remove the one to be hidden.... 
And you can keep a reference to a hidden TabPage in a WinForm module level var/array/collection/... then it will not be "garbage collected" and you can add (make visible) or remove (make invisible) it when needed...

I have never needed to hide/unhide TabPages during prev. 8 years of C# development - "the more you know the more you know that you know nothing..." - very true for .NET development's everyday practice - and this ".NET Framework behemoth"  is becoming bigger and bigger with every coming day....

Thank you.

-- Shamil 


More information about the dba-VB mailing list