Current .Net Version: 2.0.50727
Home
Articles
C# & .Net Framework Reference
Practice C# Online
XML Web Services
RSS Feeds
Code Snippets
T-SQL Scripts
Videos
Valuable Links
Contact Us
Mike's C#, VS.NET and SQL Blog




ROR XML Info.
Hiding TabPages
Author: Michael G.     Last Updated:7/15/2004 10:24:21 AM
Category(ies): Windows Forms All
Description:
  Add & View Comments About this Article



To hide a TabPage control, you have to simply remove it from the TabControl's TabPages collection property. This is the only known way to hide a TabPage from a TabControl: // removes the first TabPage object in the TabPages collection: this.tabControl1.TabPages.Remove(this.tabPage1); You normally won't have to worry about losing the TabPage control *if* it was created at the class level (rather than in a property or method).


Comments Click Here to Add your Comment
By Rafael Duluc @ 4/1/2006 10:14:50 PM

An effective way to hide and restore Windows Tabpages is by using collection object.
If you are using VB.NET 2005 then the following example will do easy.
***** Create a private object collection ******
    Private _TabPages As New System.Collections.Generic.List(Of TabPage)
'NOTE: This collection object ensure that the type of object to store is a TabPage.

********* to the event that remove the tabpage or tabpages *****
Sub MyRemoveEvent(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyRemoveEvent.Click

Dim oPage As TabPage = Nothing
        _TabPages.Clear() ' Clear any objects it may have previously. This is true if you reuse this object.

        For Each oPage In TabControl2.TabPages

                _TabPages.Add(oPage) 'here you are storing the object into the collection
                TabControl2.TabPages.Remove(oPage) ' here you are deleting the object from the TabControl


        Next
        TabControl2.Refresh() ' just a refresh. no need to but I like it.

End Sub

'****** Ok Now the event which put them back into the TabControl ********

Sub MyRestoreEvent(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyRestoreEvent.Click


        Dim oPage As TabPage = Nothing

        For Each oPage In _TabPages
              TabControl2.TabPages.Add(oPage)
            
        Next
        TabControl2.Refresh()
End Sub

'' Hope this works for you as it does for me.

Regards,
 
COPYRIGHT/DISCLAIMER | CONTACT US