本文整理汇总了C#中System.Windows.Forms.ToolStripItem.PerformClick方法的典型用法代码示例。如果您正苦于以下问题:C# ToolStripItem.PerformClick方法的具体用法?C# ToolStripItem.PerformClick怎么用?C# ToolStripItem.PerformClick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.ToolStripItem
的用法示例。
在下文中一共展示了ToolStripItem.PerformClick方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnClick_RecursivelyActivate
/// <summary>
/// Activates correct menu item by recursively going through the whole menu structure. Called from OnClick and recursively calls itself.
/// </summary>
/// <param name="item"></param>
/// <param name="next"></param>
/// <param name="forward"></param>
/// <returns></returns>
private bool OnClick_RecursivelyActivate(ToolStripItem item, ref bool next, bool forward)
{
if (!(item is ToolStripMenuItem))
return false;
if (((ToolStripMenuItem)item).DropDownItems.Count > 0)
{
for (int i = 0; i < ((ToolStripMenuItem)item).DropDownItems.Count; i++)
if (OnClick_RecursivelyActivate(((ToolStripMenuItem)item).DropDownItems[forward ? i
: ((ToolStripMenuItem)item).DropDownItems.Count - 1 - i], ref next, forward))
return true;
}
else
{
if (next)
{
item.PerformClick();
return true;
}
next = item.Selected || next;
}
return false;
}
示例2: PerformMenuClick
private bool PerformMenuClick(ToolStripItem menuItem, Keys shortCut)
{
if (menuItem is ToolStripMenuItem)
{
if ((menuItem as ToolStripMenuItem).ShortcutKeys == shortCut)
{
menuItem.PerformClick();
return true;
}
}
if (menuItem is ToolStripDropDownItem)
{
foreach (ToolStripItem item in (menuItem as ToolStripDropDownItem).DropDownItems)
{
if (PerformMenuClick(item, shortCut))
{
return true;
}
}
}
return false;
}