如果树视图有一个子节点,则禁用上下文菜单 [英] Disable context menu if the treeview has a child node

查看:89
本文介绍了如果树视图有一个子节点,则禁用上下文菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我以一种方式设计了一个应用程序,使我最初具有一个Root节点具有树视图.如果我在根节点上单击鼠标右键,将显示一个包含一些选项的上下文菜单.通过选择一个选项,我将向该根节点添加一个子节点.现在,如果树上有一个子节点,并且如果我再次右键单击,我想显示一条错误消息,因为只允许一个子节点或某些东西,或者我想禁用上下文菜单.

有人可以帮我吗

Hi all,
I have a designed an application in such a way that i will have a treeview initially with a Root node. If i right click on the root node i will have a context menu with the some options. By selecting an option i will add a child to that root node. Now if the tree has a child node and if i right click again i would like to display an error message as only one child allowed or some thing or i would like to disable the context menu.

Can any one help me please

推荐答案

选项1:
创建/添加子节点时,请禁用或不将右键单击处理程序附加到该子节点.

选项2:
将标记存储在节点-IsChild中.根据其值,如果为false,则显示上下文菜单.如果为true,则显示一条消息或忽略该事件.

试试吧!
OPTION 1:
While creating/adding a child node, disable or dont attach the right click handler to it.

OPTION 2:
Store a flag in nodes - IsChild. Based on it''s value, if false, show context menu. If true, show a message or just ignore the event.

Try!


这篇关于如果树视图有一个子节点,则禁用上下文菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆