I am trying to change the entire colorschema in my menu. And the only thing that is not changing is the toolstripseparator. I have a popupmenu where the same algorithms are used and the Effects on the popup is showed! So my question becomes: Those anyone know a solution to this??
I recursivevly loop through all the menus to set back and forecolor.
Code
private void loopmenuitems(ToolStripMenuItem item ,Color c, Color text)Code
{Code
item.BackColor = c;Code
item.ForeColor = text;Code
if (item.HasDropDownItems)Code
{Code
foreach (Object child in item.DropDownItems)Code
{Code
tryCode
{Code
ToolStripMenuItem menuitem = (ToolStripMenuItem)child;Code
loopmenuitems(menuitem, c, text);Code
}Code
catchCode
{Code
ToolStripSeparator sep = (ToolStripSeparator)child;Code
sep.ForeColor = text;Code
sep.BackColor = c;Code
}Code
}Code
}Code
}Code
private void looopMenu(Color c, Color text)Code
{Code
//Doesn't WORK
menuStrip1.BackColor = c;Code
menuStrip1.ForeColor = text;Code
foreach (Object m in menuStrip1.Items)Code
{Code
tryCode
{Code
ToolStripMenuItem items = (ToolStripMenuItem)m;Code
loopmenuitems(items, c, text);Code
}Code
catchCode
{Code
ToolStripSeparator sep = (ToolStripSeparator)m;Code
sep.ForeColor = text;Code
sep.BackColor = c;Code
}Code
}Code
// WORKS
popupmenu.BackColor = c;Code
popupmenu.ForeColor = text;Code
foreach (Object menuitem in popupmenu.Items)
{Code
tryCode
{Code
ToolStripMenuItem items = (ToolStripMenuItem)menuitem;Code
loopmenuitems(items, c, text);Code
}Code
catchCode
{Code
ToolStripSeparator sep = (ToolStripSeparator)menuitem;Code
sep.ForeColor = text;Code
sep.BackColor = c;Code
}Code
}Code
}Code |
Answers
Know the answer? Post it. Somebody with the same question will find it here.