本文整理汇总了C#中System.Windows.Forms.MenuItem.GetMainMenu方法的典型用法代码示例。如果您正苦于以下问题:C# MenuItem.GetMainMenu方法的具体用法?C# MenuItem.GetMainMenu怎么用?C# MenuItem.GetMainMenu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.MenuItem
的用法示例。
在下文中一共展示了MenuItem.GetMainMenu方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MenuItemProvider
public MenuItemProvider (SWF.MenuItem menuItem) :
base (menuItem)
{
this.menuItem = menuItem;
parentMenu = mainMenu = menuItem.GetMainMenu ();
if (parentMenu == null)
parentMenu = menuItem.GetContextMenu ();
}
示例2: GetMainMenuTest
public void GetMainMenuTest ()
{
MainMenu mymainmenu = new MainMenu ();
MenuItem mymenuitem = new MenuItem ();
mymenuitem.Text = "menu 1";
mymainmenu.MenuItems.Add (mymenuitem);
Assert.AreEqual (mymainmenu, mymenuitem.GetMainMenu (), "#7");
}
示例3: SetMenuItemText
/// <summary>
/// Sets the given menuitem's text property.
/// </summary>
/// <param name="item">MenuItem to set</param>
/// <param name="index">Index of item's parent MenuItem</param>
/// <history>
/// [Curtis_Beard] 07/31/2006 Created
/// </history>
public static void SetMenuItemText(MenuItem item, int index)
{
if (__RootNode != null)
{
string formName = item.GetMainMenu().GetForm().Name;
XmlNode node = __RootNode.SelectSingleNode("screen[@name='" + formName + "']/menu[@index='" + index + "']/menuitem[@index='" + item.Index + "']");
if (node != null)
{
if (node.Attributes["value"] != null)
item.Text = node.Attributes["value"].Value;
}
}
}
示例4: GetString
public static string GetString(MenuItem menuItem)
{
string moduleName = Assembly.GetCallingAssembly().GetName().Name;
string formName = moduleName;
Form parentForm = null;
if (null != menuItem.GetMainMenu())
{
parentForm = menuItem.GetMainMenu().GetForm();
}
else if (null != menuItem.GetContextMenu())
{
Control source = menuItem.GetContextMenu().SourceControl;
if (null != source)
{
parentForm = source.FindForm();
}
}
if (null != parentForm)
{
formName = parentForm.Name;
}
string key =
string.Format("{0}.{1}_{2}",
moduleName, formName, menuItem.Name);
string value = GetString(key, menuItem.Text);
menuItem.Text = value;
return value;
}