Good day! Is it possible to somehow disable one tab from several in C # and how to implement it? Thank you in advance.

  • A little more fun - WinForms or WPF? What class of controls are you interested in? - IAZ
  • WinForms. TabConrol. If I said something wrong, sorry, the first day on Sharpe ... - Mobyman

2 answers 2

With TabPage, you cannot set the Enabled property, with the same result as for a regular control, but you can prevent the transition to one or another tab in TabControl:

private void tabControl1_Selecting(object sender, TabControlCancelEventArgs e) { if (e.TabPage == tabPage2) e.Cancel = true; } 

    For TabControl, it is impossible to disable one of the TabPages; more precisely, TabPage has the Enabled property, but this is what is written about it:

    This item does not make sense for this control.

    There are two ways out:

    1. Simple: instead of disabling the tab, you need to delete it from the control panel
    2. Difficult: make the OwnerDrawFixed control and draw it yourself, and then you can make it "disabled" and visually make it gray.
    • Thank. Apparently it still makes sense ... :) - Mobyman
    • Glad to help :) in Russian MSDN sometimes funny pearls skip ... - IAZ