【发布时间】:2010-04-25 09:41:37
【问题描述】:
我需要知道如何使选项卡控件中的选项卡项对特定类型的用户不可用。
事情是这样的,在“登录”之后,如果用户不是管理员,他会有一两个标签不可用。管理员将有权访问整个系统。
我只想让标签不可点击。我有哪些选择?
提前致谢
【问题讨论】:
-
您使用的是 Windows 窗体还是 Web 应用程序?
标签: c# tabcontrol winforms tabpage
我需要知道如何使选项卡控件中的选项卡项对特定类型的用户不可用。
事情是这样的,在“登录”之后,如果用户不是管理员,他会有一两个标签不可用。管理员将有权访问整个系统。
我只想让标签不可点击。我有哪些选择?
提前致谢
【问题讨论】:
标签: c# tabcontrol winforms tabpage
一般:
System.Windows.Forms.TabPage.Enabled= false;
System.Windows.Forms.TabPage.Visible= false;
我更喜欢下一种方法:
tabAdmin.Visible = isAdmin;
【讨论】:
你可以试试!
tab.TabPages.Remove(tabToRemove);
How to: Add and Remove Tabs with the Windows Forms TabControl
或者更改选项卡的启用和可见状态。
if (!Admin)
{
tab.Visible = false;
tab.Enable = false;
}
【讨论】:
编辑:我的回答很笼统。
最好让它们不可见而不是不可点击。
关于向用户显示标签,请检查用户所在的角色。
这是我的伪代码..
if(User is Administrator)
{
//show the tabs
}
else
{
//dont show the tabs
}
【讨论】:
你可以这样做......
//Within Window_Loaded routine...
//Check a boolean setting you created
//If setting is set to 'not have the tab enabled' set that tabitem to hidden
if (Settings.Default.CheckConverterTabEnabled == false)
{
CheckConverterTab.Visibility = Visibility.Hidden;
}
//Otherwise, run that tab window loaded routine
else
{
CheckConverterWindowLoaded();
}
【讨论】: