简体   繁体   English

双击TreeNode复选框上的beavior

[英]Double-click beavior on a TreeNode checkbox

I have a TreeView populated with TreeNodes having icons and checkboxes. 我有一个TreeView填充TreeNodes有图标和复选框。

I've been tryig to disable the checkig/unchecking ability of some of them discarding the event in the BerforeCheck method. 我一直在尝试禁用其中一些在BerforeCheck方法中丢弃事件的BerforeCheck 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 ). 这样工作正常,直到我双击复选框:复选框的图像与其实际状态相反(如果状态为Checked=false则显示复选标记)。 I've tried to fix that changing the StateImageIndex manually in the NodeDoubleClick and BeforeClick method with no success. 我试图修复在NodeDoubleClickBeforeClick方法中手动更改StateImageIndex但没有成功。

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). 更糟糕的是:我在StateImageList添加了第三个图像(是的,我希望复选框也是三态)但我还没有使用它(它从未在我的代码中设置),第三个图像被设置为当前一些双击后的状态(此时我无法确定明确的行为)。

How can I do to at best make it work as exepected, at worst disable the double-click on the checkbox? 我怎么能最好让它按预期工作,最坏的情况是禁用双击复选框? Thanks. 谢谢。

PS: The question has already been asked , but had no answer... PS:问题已经被提出 ,但没有答案......

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);
        }
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM