本文介绍了如何设置system.windows.forms.tabcontrol单个选项卡的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Windows窗体应用程序中,我添加了一个System.Windows.Forms.TabControl对象(此处称为tabControlMain)。它包含多个选项卡。在Designer.cs中,2个选项卡被添加到tabControlMain中。

In my Windows Form Application, I added a System.Windows.Forms.TabControl object (termed tabControlMain here). It contains multiple tabs. In the Designer.cs, the 2 tabs are added into tabControlMain.

this.tabControlMain.Controls.Add(this.tpMain);
     this.tabControlMain.Controls.Add(this.tpViewData);



我想设置一个单独的标签(例如tpViewData).Enabled和.Visible动态。但是,单个选项卡没有.Enabled和.Visible属性。如何解决这个问题呢?谢谢。



我尝试过:



设置System.Windows .Forms.TabControl单个选项卡的属性


I want to set an individual tab (e.g. tpViewData) .Enabled and also .Visible dynamically. However, the individual tab does not have the .Enabled and .Visible properties. How to solve this problem? Thanks.

What I have tried:

Set System.Windows.Forms.TabControl individual tab's properties

推荐答案

tabPage1.Visible = false;
tabPage2.Enabled = false;

您的代码将编译。



但它们没有效果。



您无法禁用或隐藏标签页 - 您只能从父TabControl的TabPages集合中删除它,或者添加一个面板,它填充标签页并使用它的Enabled属性。

And your code will compile.

But they will have no effect.

You cannot disable or hide a tabpage - you can only remove it from the TabPages collection of the parent TabControl, or add a Panel which fills the tab page and use the Enabled property of that.


这篇关于如何设置system.windows.forms.tabcontrol单个选项卡的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 22:35