private void loopmenuitems(ToolStripMenuItem item ,Color c, Color text)
{
item.BackColor = c;
item.ForeColor = text;
if (item.HasDropDownItems)
{
foreach (Object child in item.DropDownItems)
{
try
{
ToolStripMenuItem menuitem = (ToolStripMenuItem)child;
loopmenuitems(menuitem, c, text);
}
catch
{
ToolStripSeparator sep = (ToolStripSeparator)child;
sep.ForeColor = text;
sep.BackColor = c;
}
}
}
}
private void looopMenu(Color c, Color text)
{
//Doesn't WORK
menuStrip1.BackColor = c;
menuStrip1.ForeColor = text;
foreach (Object m in menuStrip1.Items)
{
try
{
ToolStripMenuItem items = (ToolStripMenuItem)m;
loopmenuitems(items, c, text);
}
catch
{
ToolStripSeparator sep = (ToolStripSeparator)m;
sep.ForeColor = text;
sep.BackColor = c;
}
}
// WORKS
popupmenu.BackColor = c;
popupmenu.ForeColor = text;
foreach (Object menuitem in popupmenu.Items)
{
try
{
ToolStripMenuItem items = (ToolStripMenuItem)menuitem;
loopmenuitems(items, c, text);
}
catch
{
ToolStripSeparator sep = (ToolStripSeparator)menuitem;
sep.ForeColor = text;
sep.BackColor = c;
}
}
}