Double-click behavior in the TreeNode window

I have a TreeView populated using TreeNodes that has icons and checkboxes.

I am trying to disable check / BerforeCheck some of them by throwing an event in the BerforeCheck method. This works fine until I double-click on the flag: the image of the flag is opposite to its actual state (it shows a check mark if the status is Checked=false ). I tried to fix this manually by changing StateImageIndex in the NodeDoubleClick and BeforeClick without success.

Even worse: I added a third image to StateImageList (yes, I want the checkboxes to be three-states too), but I still don't use it (it is never set in my code), and the third image is set as the current state of the window after some double-click (at this moment I can’t define a clear behavior).

How can I at best make it work as exepected, in the worst case, disable double-clicking on the checkbox? Thanks.

PS: the question already was, but there was no answer ...

+4
source share
1 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); } } 
+4
source

Source: https://habr.com/ru/post/1343886/


All Articles