Treeview DoubleClick问题 [英] Treeview DoubleClick Problem
本文介绍了Treeview DoubleClick问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我在双击树视图时遇到问题.我想避免双击树视图的+/-时双击树视图.请任何人告诉我,如何避免这种情况?
Hello,
I have a problem on Double click of tree view. I want to avoid double click of tree view when double click on +/- of tree view. please anyone tell me, How to avoid this?
thanks in advance.
推荐答案
您无法避免双击:用户单击所需的次数. :-)
—SA
You cannot avoid double click: the user clicks as many time as she/he wants. :-)
—SA
您不能双击树节点的+/-.单击即可展开和折叠节点.我试图抑制双击,但正如SAKryukov所说,不可能做到这一点.这是因为事件BeforeExpand
在事件MouseDoubleClick
之前得到处理,否则我们可以通过在BeforeExpand
事件中设置e.Cancel = true
来取消节点的扩展.
这是我尝试过的方法:
You cannot doubleclick on the +/- of the treenodes. The nodes expand and collapse on a single click. I tried suppressing the doubleclick but as SAKryukov says, its not possible to do that. Its because the eventBeforeExpand
gets handled before the eventMouseDoubleClick
, otherwise we could have cancelled the expansion of nodes by setting thee.Cancel = true
in theBeforeExpand
event.
Here is how I tried:
private bool isDoubleClick = false;
void treeView1_MouseDoubleClick(object sender, MouseEventArgs e)
{
isDoubleClick = true;
}
//But this event is called before MouseDoubleClick so isDoubleClick will be false.
void treeView1_BeforeExpand(object sender, TreeViewCancelEventArgs e)
{
if (isDoubleClick == true)
{
e.Cancel = true;
}
}
这篇关于Treeview DoubleClick问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文