For my current project i made a MDIform with "menuStrip" and a couple of "ToolStripMenuItem". a couple of buttons and a devexpress "NavbarControl"
The intention is that the user logs in with a userID the application will get a datarow for a specific "Control" in this row theirs a bool, if its true the Item must be visible, otherwise the item must be invisible.
the Datarow also contains the name of the item.
so i uses:
this.Controls[item].Visible = true;
item = string(name of item)
if i use this to hide the menustrip itself, it works if i try it on the MenuStipItems, it gives a null reference exception.
how can i control the items INSIDE the MenuStip, only by name of the item???
Code:
DataTable dt = GetData();
foreach (DataRow row in dt.Rows)
{
string item = row["ItemNaam"].ToString();
foreach (string rol in Rollen)
{
DataRow dr = GetDataByItemNaam(item);
if (Convert.ToBoolean(dr[rol]) == true)
{
this.Controls[item].Visible = true; //Show Item
}
}
}