Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • How to Hide TabPages dynamicaly

    • 0
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 633
    Answer it

    I am working on Windows application using c#, in which I am using a TabControl. What I have to do is to open a tabpage dynamicaly on user's choice i.e if the user clicks on the NewUser button then the "New User" tabpage should get open & if the user clicks the Login button then the "Log In" tabpage should get open & the current tabpage should get close.

    I acheived this by using following methods:


    But the problem is that when I remove the tabpages I am not able to get them back...! Please give some solution..? Thanks in advance !

 1 Answer(s)

  • Hi Mayank,
        The best solution I can suggest is that as you remove the TabPages from the Tab Control, keep the removed pages in the list so that you can get them later...

    Please go through the following example this will give you the exact idea I am talking about:

    private List<TabPage> removedPages = new List<TabPage>();
        private void EnablePage(TabPage page, bool enable) {
            if (enable) {
            else {
        protected override void OnFormClosed(FormClosedEventArgs e) {
            foreach (var page in removedPages) page.Dispose();
Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: