首先需要对工作空间树下面的不同节点设置不同的右键菜单:
这里举例对数据源节点设置一个右键菜单,其他节点同样的用法;
workspaceControl1.WorkspaceTree.DatasourcesNode.ContextMenuStrip = contextMenuStripDatasources;
为矢量数据集创建右键菜单:
workspaceControl1.WorkspaceTree.NodeContextMenuStrips[WorkspaceTreeNodeDataType.DatasetVector] = contextMenuStripDatasetVector;
然后对workspaceControl1_WorkspaceTree_NodeMouseClick注册对应的事件,获取到
WorkspaceTreeNodeBase node = e.Node as WorkspaceTreeNodeBase;
通过node.NodeType去判定对应的节点类型,获取到对应的数据,然后做对应的操作