I found the answer! See the code below:
It appears that the parent object is revealed by a method rather than a
property.
So the code I needed after changing to ToolStripMenuItem types was
"mnuItem.GetCurrentParent().Items"
private void mnuColorItem_Click(
object sender, System.EventArgs e)
{
ToolStripMenuItem mnuItem = (ToolStripMenuItem)sender;
//Get the color name from the menu item text
//while removing the & character in that text
rbText.SelectionColor = Color.FromName(
mnuItem.Text.Replace("&", ""));
//Uncheck all menu items inside the color menu
foreach (ToolStripMenuItem m in
mnuItem.GetCurrentParent().Items)
m.Checked = false;
mnuItem.Checked = true;
}
"Cor Ligthert [MVP]" <no************@planet.nlwrote in message
news:eg**************@TK2MSFTNGP05.phx.gbl...
Henry,
You can use in version 2005 the same menus as in version 2003, there is no
need for the language to use toolstrips, which are of course other classes
with their own methods.
Cor
"Henry" <he*********@myquest-tech.comschreef in bericht
news:uB**************@TK2MSFTNGP03.phx.gbl...
>>I am trying to convert code that worked in a Visual Studio 2003 project to
code that will work in a Vsual Studio 2005 project
and need help.
The following is the VS2003 code:
private void mnuColorItem_Click(
object sender, System.EventArgs e)
{
MenuItem mnuItem = (MenuItem)sender;
//Get the color name from the menu item text
//while removing the & character in that text
rbText.SelectionColor = Color.FromName(
mnuItem.Text.Replace("&", ""));
//Uncheck all menu items inside the color menu
foreach (MenuItem m in mnuItem.Parent.MenuItems)
m.Checked = false;
mnuItem.Checked = true;
}
In VS 2005 this doesn't work because the menu is now a ToolStrip and
MenuItem is now a ToolStripMenuItem...
But when I change that then I can't access the parent because it is
protected. I am not sure what I have to change to get at that data....
That is what I need help with right now.