本文整理汇总了C#中System.Windows.Forms.MenuItem.GetContextMenu方法的典型用法代码示例。如果您正苦于以下问题:C# MenuItem.GetContextMenu方法的具体用法?C# MenuItem.GetContextMenu怎么用?C# MenuItem.GetContextMenu使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.MenuItem
的用法示例。
在下文中一共展示了MenuItem.GetContextMenu方法的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: GetContextMenuTest
public void GetContextMenuTest ()
{
Form myform = new Form ();
myform.ShowInTaskbar = false;
ContextMenu mycontextmenu = new ContextMenu ();
myform.ContextMenu= mycontextmenu;
MenuItem menuItem1 = new MenuItem ();
menuItem1.Text = "1";
mycontextmenu.MenuItems.Add (menuItem1);
Assert.AreEqual (mycontextmenu, menuItem1.GetContextMenu (),"#1");
myform.Dispose ();
}
示例3: GetSourcePicture
private PictureBox GetSourcePicture(MenuItem SourceMenu)
{
if (SourceMenu != null) {
ContextMenu CM = SourceMenu.GetContextMenu();
if (CM != null)
return CM.SourceControl as PictureBox;
}
return null;
}
示例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;
}