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


C# TreeView.add_ContextMenu方法代码示例

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


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

示例1: addEditMenuItemsToTreeView

		public void addEditMenuItemsToTreeView(TreeView treeView)
        {
        	var contextMenu = treeView.add_ContextMenu(); 
			contextMenu.add_MenuItem("delete selected page (you must be an admin)",
							()=>{
									var pageToDelete = treeView.selected().get_Text();
									if (pageToDelete.valid()) 
										if (WikiApi.deletePage(pageToDelete)) 
											treeView.remove_Node(treeView.selected());													
								});	
								
		/*	contextMenu.add_MenuItem("reload all pages",
							()=>{
									treeView.clear();
									treeView.add_Nodes(WikiApi.allPages());
								}); 
		*/						
			var renameMenuItem = contextMenu.add_MenuItem("rename (user will copy, admin will move)");
			var renameTextBox = renameMenuItem.add_TextBox("rename");		   					   
			
			renameMenuItem.add_MenuItem("rename page with new title (set above)",
					()=> {
							var currentTitle = treeView.selected().get_Text();
							var newTitle = renameTextBox.get_Text(); 
							if (WikiApi.movePage(currentTitle, newTitle))
							{
								treeView.selected().set_Text(newTitle);								
							}
							//"renaming page '{0}' to '{1}'".info(currentTitle, newTitle);
						});
			treeView.afterSelect<string>(
					(page)=> 
							{								
								renameTextBox.set_Text(page);
								renameTextBox.width(page.size() * 7);								
							});						
        }
开发者ID:jobyjames85,项目名称:O2.Platform.Scripts,代码行数:37,代码来源:MediaWikiEditor.cs

示例2: buildGui


//.........这里部分代码省略.........

                LinkLabel invokeLink = null;
                invokeLink = optionsPanel.add_CheckBox("Show Methods", 0, 0,
                                (value) =>
                                {
                                    ShowMethods = value;
                                    invokeLink.enabled(value);
                                    refresh();
                                })
                                         .append_Link("invoke", invokeSelectedMethod)
                                            .leftAdd(-16).topAdd(5).bringToFront()
                                            .enabled(false);

                optionsPanel.add_CheckBox("Show Property and Field info", 22, 0,
                    (value) =>
                    {
                        ShowPropertyAndFieldInfo = value;
                        refresh();
                    })
                            .autoSize()
                            .append_Link("refresh", () => refresh())
                            .left(200);
                optionsPanel.add_CheckBox("Sort Values", 0, 135,
                    (value) =>
                    {
                        Sorted = value;
                        try
                        {
                            treeView.sort(Sorted);  // throwing "Unable to cast object of type 'System.Boolean' to type 'System.Windows.Forms.TreeView'"
                        }
                        catch//(Exception ex)
                        {
                            //ex.log();
                        }
                    })[email protected](true);

                simpleView_CheckBox = optionsPanel.add_CheckBox("Simple View", 0, 220,
                    (value) =>
                    {
                        SimpleView = value;
                        //propertyGrid.splitContainer().panel1Collapsed(value);
                        refresh();
                    })
                            .bringToFront();

                /*showSerializedString_CheckBox = optionsPanel.add_CheckBox("Show serialized string", 44, 0,
                    (value) =>
                    {
                        ShowSerializedString = value;
                        serializedStringPanel.panel2Collapsed(!value);
                        refresh();
                    })
                             .autoSize();*/

                createObjectWhenNull_CheckBox = optionsPanel.add_CheckBox("Create Object When Null", 44, 150,
                    (value) =>
                    {
                        CreateObjectWhenNull = value;
                    })
                            .bringToFront()
                            .autoSize();

                treeView.afterSelect<object>(
                    (selectedObject) =>
                    {
                        var treeNode = treeView.selected();
                        objectName.set_Text(treeNode.get_Text());
                        var tag = WinForms_ExtensionMethods_TreeView.get_Tag(treeNode);
                        if (tag.notNull())// && tag.str() != treeNode.get_Text())
                        {
                            propertyGrid.show(selectedObject);
                            var toString = selectedObject.str();
                            if (toString == "System.__ComObject")
                                toString += " : {0}".format(selectedObject.comObject_TypeName());
                            toStringValue.set_Text(toString);

                            propertyGrid.parent().set_Text(selectedObject.typeFullName());
                            if (treeNode.nodes().size() == 0)
                            {
                                addObjectPropertyAndFields(treeNode, selectedObject);
                            }
                        }
                        else if (treeNode.nodes().size() == 0)
                        {
                            propertyGrid.show(null as object);
                            propertyGrid.parent().set_Text("[null value]");
                            toStringValue.set_Text("[null value]");
                            objectName.set_Text("");
                            treeNode.color(Color.Red);
                        }

                    });
                treeView.add_ContextMenu().add_MenuItem("Invoke Method", () => invokeSelectedMethod());
            }
            catch (Exception ex)
            {
                ex.log("in buildGui", true);
            }
            guiReady = true;
        }
开发者ID:njmube,项目名称:FluentSharp,代码行数:101,代码来源:ctrl_ObjectViewer.cs


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