I am trying to locate a field (ToolStripMenuItem) by name in the current form
and set its Enabled property, but I'm having no luck (skill) so far.
Any help you could provide wold be greatly appreciated.
This is the code I have so far. The line using (ToolStripMenuItem field =
GetField(name)) is where I need to grab a reference to the field to affect,
and obviously the existing code is not correct, but it should give you the
idea.
private void SetSecurityOnMenu()
{
string name = String.Empty;
Constants.GUIObjectRestrictions restriction =
Constants.GUIObjectRestrictions.None;
statusStrip1.Items[0].Text = "Setting security on menu items...";
// Get the list of objects on this form that have restrictions
ArrayList l =
BL.SecuredGUIObjectRestrictions.GetSecuredGUIObjec tRestrictionsForParent(this.Name, Common.CommaDelimitedSecurityGroupList(MyPrincipal ));
for (int i = 0, limit = l.Count; i < limit; i++)
{
name = ((GUIObjectRestrictions)l[i]).ObjectName;
restriction = ((GUIObjectRestrictions)l[i]).Restriction;
using (ToolStripMenuItem field = GetField(name))
{
if (restriction == Constants.GUIObjectRestrictions.Disable)
{
field.Enabled = false;
}
}
}
statusStrip1.Items[0].Text = String.Empty;
}