I'm working on a MDI Windows Forms
application. My parent form has ToolStrip
menu and some ToolStripDropDownButtons
. I want to change the Visible
property of the ToolStripDropDownButton
or to some of the ToolStripItems
(sub buttons) that it has accordingly to the permission of the user.
Here is the part of the method that I've wrote to manage this:
private void SetToolStripDropDownVisibility(ToolStripDropDownButton mainBtn, params ToolStripItem[] item)
{
mainBtn.Visible = false;
foreach (ToolStripItem tempItem in item)
{
tempItem.Visible = true;
}
}
I'm passing as first argument the ToolStripDropDownButton
and all other "sub buttons" as params list. However when I get into debug mode in the part foreach (ToolStripItem tempItem in item)
the tempItem
Visible property is marked as false. In the designer however this property is set to true. You can see that I even try explicitly to change the value to true - tempItem.Visible = true;
but it seems as if this line is doing nothing. The value of Visible
remains false
and I can't change it.
This is just the begining of the method and I can't think of other code that can mess up with the ToolStrip
items. I tried to change the value of mainBtn.Visible
to true or false thinking that maybe there's any connection but it seems this is not the issues. So any idea why this is happening, why I cant change the Visible
value and of course any way to do it.