How to hide / lock a tab in C #?
I need to know how to make a tab control in a tab control inaccessible to a specific user.
The fact is that after creating a "login", if the user is not an administrator, he will have one or two tabs inaccessible. The administrator will have access to the entire system.
I just want to make the tabs un-clickable. What are my options?
Thanks in advance
a source to share
Generally:
System.Windows.Forms.TabPage.Enabled
= false;
System.Windows.Forms.TabPage.Visible
= false;
I prefer the following approach:
tabAdmin.Visible = isAdmin;
a source to share
you can try!
tab.TabPages.Remove(tabToRemove);
How to add and remove tabs with TabControl Windows Forms
Or change the enable and visibility state of the tab.
if (!Admin)
{
tab.Visible = false;
tab.Enable = false;
}
a source to share
You can do it like this:
//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();
}
a source to share