I have a ToolStripMenu
with several ToolStripDropDownButtons
. Those dropDownButtons have ToolStripMenuItems
on themselves (sub buttons). I need to set visibility permission and the issue is that a user may have permissions only for some tsMenuItems or may be omitted from seeing all the item in a certain dropDownButton then the whole ToolStripDropDownButtons
should be set to Visible = false
.
The rights for the visibility are set in a public Enum
like this:
[EnumValue("Clients")]
Clients = 1,
[EnumValue("Materials")]
Materials = 2,
[EnumValue("Uppers")]
and so on...
I started to write a method but the the logic it is based on is that each ToolStripItem
is named just like the EnumValue
. So what I need (if possible) is somehow to do that:
private void SetToolStripDropDownVisibility(ToolStripDropDown mainBtn, params ToolStripItem[] item)
{
foreach (ToolStripItem tempItem in item)
{
EnumValue eValue = tempItem.Text;
if (Helpers.GrantActivity(ControlEnum.eValue, ActionEnum.ShowMenuItem))
}
}
- First if possible is to use
tempItem.Text
asEnumValue
what I tried here, but obviously need some casting or other -EnumValue eValue = tempItem.Text;
and the call the helper method with a correct argument -ControlEnum.eValue
which as it seems to me still depends on that if I can usetempItem.Text
asEnumValue
.