在TreeNode复选框上双击beavior [英] Double-click beavior on a TreeNode checkbox
问题描述
我有一个 TreeView
,其中装有 TreeNodes
有图标和复选框。
I have a TreeView
populated with TreeNodes
having icons and checkboxes.
我一直试图在 BerforeCheck
方法中禁用其中一些丢弃事件的checkig / uncheck功能。在我双击该复选框之前,它工作正常:该复选框的图像与其实际状态相反(如果状态为 Checked = false
,则会显示一个复选标记)。我试图解决在 NodeDoubleClick
和 BeforeClick
方法中手动更改StateImageIndex失败的问题。
I've been tryig to disable the checkig/unchecking ability of some of them discarding the event in the BerforeCheck
method. This works fine, until I double click on the checkbox: the image of the checkbox is the opposite of its real state (it shows a check mark if the status is Checked=false
). I've tried to fix that changing the StateImageIndex manually in the NodeDoubleClick
and BeforeClick
method with no success.
更糟糕的是:我在 StateImageList
中添加了第三张图像(是的,我也希望复选框也处于三态),但是我还没有使用它(从未在我的代码中设置过),并且双击后第三张图像被设置为盒子的当前状态(此时我无法确定明确的行为)。
Even worse: I added a third image in the StateImageList
(yes I want the checkboxes to be tri-state too) but I'm not using it yet (it's never set in my code), and the third image is set as the current state of the box after some double-click (at this point I can't determine a clear behavior).
我该如何做到最好,如预期的那样工作,最糟糕的是禁用复选框的双击?
谢谢。
How can I do to at best make it work as exepected, at worst disable the double-click on the checkbox? Thanks.
PS:问题有已被问到,但没有答案...
PS: The question has already been asked, but had no answer...
推荐答案
尝试一下.. :)为我工作
Try this.. :) worked for me
public class NewTreeView : TreeView
{
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x203)
m.Result = IntPtr.Zero;
else
base.WndProc(ref m);
}
}
这篇关于在TreeNode复选框上双击beavior的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!