如何禁用一个TabControl内的标签? [英] How can I disable a tab inside a TabControl?

查看:152
本文介绍了如何禁用一个TabControl内的标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在的 TabControl的

我使用C#。

推荐答案

TabPage的类隐藏启用属性。这是故意的,因为是一个尴尬的UI设计问题的。基本的问题是,禁用页面不也禁用选项卡,然后在选择事件禁用标签不起作用的 TabControl的只有一个页面。

The TabPage class hides the Enable property. That was intentional as there's an awkward UI design problem with it. The basic issues are that disabling the page does not also disable the tab and disabling the tab with the Selecting event doesn't work when the TabControl has only one page.

它仍然有效;你可以硬code启用属性赋值。如果 FUD 是不舒服,那么你可以简单地做到这一点:

It still works; you can hard-code the Enable property assignment. If the FUD is uncomfortable then you can simply do this:

public static void EnableTab(TabPage page, bool enable) {
    foreach (Control ctl in page.Controls) ctl.Enabled = enable;
}

这篇关于如何禁用一个TabControl内的标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆