当前位置: 首页>>代码示例>>C#>>正文


C# ToolStripMenuItem.GetCurrentParent方法代码示例

本文整理汇总了C#中System.Windows.Forms.ToolStripMenuItem.GetCurrentParent方法的典型用法代码示例。如果您正苦于以下问题:C# ToolStripMenuItem.GetCurrentParent方法的具体用法?C# ToolStripMenuItem.GetCurrentParent怎么用?C# ToolStripMenuItem.GetCurrentParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Forms.ToolStripMenuItem的用法示例。


在下文中一共展示了ToolStripMenuItem.GetCurrentParent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FindParent

        private Form FindParent(ToolStripMenuItem item)
        {
            Form parentForm = null;
            if (item.GetCurrentParent() is ContextMenuStrip) {
                ContextMenuStrip contextMenu = item.GetCurrentParent() as ContextMenuStrip;
                if (contextMenu.SourceControl != null) {
                    parentForm = contextMenu.SourceControl.FindForm();
                }
                else {
                    parentForm = contextMenu.FindForm();
                }
            }
            else if (item.GetCurrentParent() is ToolStrip) {
                parentForm = item.GetCurrentParent().FindForm();
            }

            return parentForm;
        }
开发者ID:anand-ajmera,项目名称:cornell-urban-challenge,代码行数:18,代码来源:PlanningGridExtDisplayObject.cs

示例2: GetCurrentParent

		public void GetCurrentParent ()
		{
			ToolStripMenuItem tsmiFile = new ToolStripMenuItem ("File");
			ToolStripMenuItem tsmiHelp = new ToolStripMenuItem ("Help");
			ToolStripMenuItem tsmiQuit = new ToolStripMenuItem ("Quit");
			ToolStripMenuItem tsmiAbout = new ToolStripMenuItem ("About");
			tsmiFile.DropDownItems.Add (tsmiQuit);
			tsmiHelp.DropDownItems.Add (tsmiAbout);
			MenuStrip menu = new MenuStrip ();
			menu.Items.Add (tsmiFile);
			menu.Items.Add (tsmiHelp);
			
			ToolStrip parent = tsmiFile.GetCurrentParent ();
			Assert.IsNotNull (parent, "A1");
			Assert.AreEqual (parent.GetType ().Name, typeof (MenuStrip).Name, "A2");
			Assert.AreEqual (parent, menu, "A3");
			
			//because it's not visible?:
			Assert.IsNull (tsmiQuit.GetCurrentParent (), "A4");
		}
开发者ID:KonajuGames,项目名称:SharpLang,代码行数:20,代码来源:ToolStripMenuItemTest.cs

示例3: SetCheckedToolTip

 private void SetCheckedToolTip(ToolStripMenuItem item, bool state)
 {
     if (item == null)
         return;
     if (item.GetCurrentParent() == null)
         return;
     if (item.GetCurrentParent().InvokeRequired)
     {
         SetCheckedToolTipCB d = new SetCheckedToolTipCB(SetCheckedToolTip);
         item.GetCurrentParent().Invoke(d, new object[] { item, state });
     }
     else
     {
         item.Checked = state;
     }
 }
开发者ID:jfarre20,项目名称:Ubiquitous,代码行数:16,代码来源:MainForm.cs

示例4: GetMenuItemFromString

	public void GetMenuItemFromString(string path, ToolStripMenuItem item)
	{
		if (path.ToLower().StartsWith("new/")) {
			ToolStripMenuItem toolstrip = null;
			string path2 = path.Substring("new/".Length);
			foreach (ToolStripMenuItem item2 in Parent.MenuStrip.Items) {
				if (item2.Text == path2) {
					toolstrip = item2;
				}
			}
			ToolStripMenuItem tmpitem = new ToolStripMenuItem("[plugin helper]") { Name = "pluginhelper" };
			if (toolstrip == null) {
				toolstrip = new ToolStripMenuItem(path2, null, new ToolStripMenuItem[] { tmpitem });
			} else {
				toolstrip.DropDownItems["pluginhelper"].GetCurrentParent().Items.Add(item);
				return;
			}
			tmpitem.Visible = false;
			//Parent.MenuStrip.Items.Insert(Parent.MenuStrip.Items.IndexOfKey("INSERT"), toolstrip);
                        Parent.MenuStrip.Items.Add(toolstrip);
			//toolstrip.Owner = Parent.MenuStrip
			tmpitem.GetCurrentParent().Items.Add(item);
			return;
		} else if (path.ToLower().StartsWith("file")) {
			Parent.newToolStripMenuItem1.GetCurrentParent().Items.Add(item);
			return;
		} else if (path.ToLower().StartsWith("tools")) {
			Parent.optionsToolStripMenuItem1.GetCurrentParent().Items.Add(item);
			return;
		} else if (path.ToLower().StartsWith("help")) {
			Parent.helpToolStripMenuItem2.GetCurrentParent().Items.Add(item);
			return;
	    } else if (path.ToLower().StartsWith("build")) {
	        Parent.buildToolStripMenuItem.GetCurrentParent().Items.Add(item);
	        return;
	    }
		Parent.pluginsToolStripMenuItem.GetCurrentParent().Items.Add(item);
		return;
	}
开发者ID:mlnlover11,项目名称:MP.LSharp,代码行数:39,代码来源:PluginManager.cs

示例5: GetMenuItemFromString

 public void GetMenuItemFromString(string path, int index, ToolStripMenuItem item)
 {
     if (path.ToLower().StartsWith("new/")) {
         ToolStripMenuItem toolstrip = null;
         string path2 = path.Substring("new/".Length);
         foreach (ToolStripMenuItem item2 in MainForm.Instance.MenuStrip.Items) {
             if (item2.Text == path2) {
                 toolstrip = item2;
             }
         }
         ToolStripMenuItem tmpitem = new ToolStripMenuItem("[plugin helper]") { Name = "pluginhelper" };
         if (toolstrip == null) {
             toolstrip = new ToolStripMenuItem(path2, null, new ToolStripMenuItem[] { tmpitem });
         } else {
             if (index > toolstrip.DropDownItems["pluginhelper"].GetCurrentParent().Items.Count)
                 toolstrip.DropDownItems["pluginhelper"].GetCurrentParent().Items.Add(item);
             else
                 toolstrip.DropDownItems["pluginhelper"].GetCurrentParent().Items.Insert(index, item);
             return;
         }
         tmpitem.Visible = false;
         MainForm.Instance.MenuStrip.Items.Add(toolstrip);
         //toolstrip.Owner = MainForm.Instance.MenuStrip
         if (index > tmpitem.GetCurrentParent().Items.Count)
             tmpitem.GetCurrentParent().Items.Add(item);
         else
             tmpitem.GetCurrentParent().Items.Insert(index, item);
         return;
     } else if (path.ToLower().StartsWith("file")) {
         if (index > MainForm.Instance.newToolStripMenuItem.GetCurrentParent().Items.Count)
             MainForm.Instance.newToolStripMenuItem.GetCurrentParent().Items.Add(item);
         else
             MainForm.Instance.newToolStripMenuItem.GetCurrentParent().Items.Insert(index, item);
         return;
     } else if (path.ToLower().StartsWith("tools")) {
         if (index > MainForm.Instance.optionsToolStripMenuItem.GetCurrentParent().Items.Count)
             MainForm.Instance.optionsToolStripMenuItem.GetCurrentParent().Items.Add(item);
         else
             MainForm.Instance.optionsToolStripMenuItem.GetCurrentParent().Items.Insert(index, item);
         return;
     } else if (path.ToLower().StartsWith("help")) {
         if (index > MainForm.Instance.helpToolStripMenuItem.GetCurrentParent().Items.Count)
             MainForm.Instance.helpToolStripMenuItem.GetCurrentParent().Items.Add(item);
         else
             MainForm.Instance.helpToolStripMenuItem.GetCurrentParent().Items.Insert(index, item);
         return;
     } else if (path.ToLower().StartsWith("macros")) {
         if (index > MainForm.Instance.macrosToolStripMenuItem.DropDownItems[0].GetCurrentParent().Items.Count)
             MainForm.Instance.macrosToolStripMenuItem.DropDownItems[0].GetCurrentParent().Items.Add(item);
         else
             MainForm.Instance.macrosToolStripMenuItem.DropDownItems[0].GetCurrentParent().Items.Insert(index, item);
         return;
     }
     if (index > MainForm.Instance.optionsToolStripMenuItem.GetCurrentParent().Items.Count)
         MainForm.Instance.optionsToolStripMenuItem.GetCurrentParent().Items.Add(item);
     else
         MainForm.Instance.optionsToolStripMenuItem.GetCurrentParent().Items.Insert(index, item);
     return;
 }
开发者ID:mlnlover11,项目名称:Notepad-X,代码行数:59,代码来源:PluginManager.cs


注:本文中的System.Windows.Forms.ToolStripMenuItem.GetCurrentParent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。