ToolStripMenuItemFinder should have a Match function especially the Match function should allow the use of menu text instead of item name
i.e. add the following method
private bool Matches(string name, ToolStripItem menu)
{
object m = menu;
string[] names = name.Split('.');
for (int i = names.Length - 1; i >= 0; i--)
{
if (m == null)
{
return false;
}
//for a menu item, uses text instead of name because
//there is no name property in .NET 1.0 which is confusing.
string text = null;
if (m is ToolStripItem)
{
ToolStripItem me = m as ToolStripItem;
text = me.Text.Replace("&", string.Empty).Replace(".", string.Empty);
}
if (text == null || !names[i].Equals(text))
{
// for .NET 2.0 there is a name but we keep the old behaviour
// using text for backward compatibility
if (m is ToolStripItem)
{
ToolStripItem me = m as ToolStripItem;
if (!names[i].Equals(me.Name))
{
return false;
}
}
else
{
return false;
}
}
m = Parent(m);
}
return true;
}
and change the following line
if (string.Equals(itemName, item.Name))
to
if (Matches(itemName, item))
br Jens