TreeView 控件节点的checkbox双击BUG

  在TreeView 控件上,如果双击任何一个节点的checkbox 只会收到一次After_Check事件 但是check属性变化两次(从false到true 再从true到false),解决方案:

这是Vista和Win7的Bug
有个屏蔽双击的解决方法(不完美,无法双击折叠展开节点了):
using System;
using System.Windows.Forms;

public class MyTreeView : TreeView {
  protected override void WndProc(ref Message m) {
    // Suppress WM_LBUTTONDBLCLK
    if (m.Msg == 0x203) { m.Result = IntPtr.Zero; }
    else base.WndProc(ref m);
  }
}
Yes, this is a bug in Vista.  Add a new class to your project and paste the code shown below.  Compile.  Drop the new control from the toolbox onto your form.

using System;
using System.Windows.Forms;

public class MyTreeView : TreeView {
  protected override void WndProc(ref Message m) {
    // Suppress WM_LBUTTONDBLCLK
    if (m.Msg == 0x203) { m.Result = IntPtr.Zero; }
    else base.WndProc(ref m);
  }
}

posted on 2014-07-25 11:34  IOTer  阅读(553)  评论(0编辑  收藏  举报

导航