disable tabpage in windows appplication??

Last post 02-22-2007, 11:57 AM by cosijuan. 2 replies.
Sort Posts: Previous Next
  •  01-05-2007, 7:12 AM Post number 12438

    disable tabpage in windows appplication??

     

    Hi.

    I have a windows application in c#. In the application i have put a tabcontrol, which has 2 tabpages. In the form load, i want to disable the tabpage2. How to disable the tabpage2?

  •  01-15-2007, 12:57 AM Post number 14961 in reply to post number 12438

    Re: disable tabpage in windows appplication??

    Hi.

      I found out the answer..

    You cannot do that with the built in TabControl or TabPage classes... instead your best bet would simply be to remove the tab page in question and then re-add it to the collection when you want it to be selectable again.

             //Remove tab page
             tabControl1.TabPages.Remove(tabPage2);

             //Insert at index 1
             tabControl1.TabPages.Insert(1, tabPage2);

  •  02-22-2007, 11:57 AM Post number 19176 in reply to post number 14961

    Re: disable tabpage in windows appplication??

    Hello, i´m from México City.

    The problem resolved creating class inherit from TabPage and puclic two methods Deshabilitar() and Habilitar(); i test the follow code and is functionally:

    using System;

    using System.Collections.Generic;

    using System.Text;

    using System.Windows.Forms;

    namespace Controls

    {

       public class MyTabPage : TabPage

       {

             public void Deshabilitar()

             {

                      ((Control)this).Enabled = false;

             }

             public void Habilitar()

             {

                   ((Control)this).Enabled = true;

             }

       }

    }

    My english is bad.

View as RSS news feed in XML