更新时间:2021-12-30 07:40:02
我认为这是TreeView中的错误( http://social.msdn.microsoft.com/Forums/zh-美国/ winforms / thread / 9d717ce0-ec6b-4758-a357-6bb55591f956 / )。您需要对树视图进行子类化并禁用双击消息才能对其进行修复。像这样:
This is a bug in the TreeView I think (http://social.msdn.microsoft.com/Forums/en-US/winforms/thread/9d717ce0-ec6b-4758-a357-6bb55591f956/). You need to subclass the tree view and disable the double-click message in order to fix it. Like this:
public class NoClickTree : TreeView
{
protected override void WndProc(ref Message m)
{
// Suppress WM_LBUTTONDBLCLK
if (m.Msg == 0x203) { m.Result = IntPtr.Zero; }
else base.WndProc(ref m);
}
};
当然,如果这样做,您将不再能够使用双击隐喻在树视图中查看其他内容(例如,双击节点以启动属性页等)。
Of course if you do this you'll no longer be able to use the double-click metaphor in the tree-view for other things (such as double click a node to launch a property page, or something).