C#树视图忽略双击只在复选框双击、只在、视图、复选框

2023-09-03 16:24:54 作者:ღ猜不透

我有一个复选框一个TreeView,我想禁用双击,只有当这是在复选框完成。

I have a treeview with checkbox, I'm trying to disable the double click only when this is done in the checkbox.

我找到了一种方法来完全禁用双击,但它不是我想要的。

I found a way to totally disable the double click but it was not what I wanted.

我AP preciate,如果你能帮助我。

I appreciate if you can help me.

推荐答案

如果你只是想知道一个DoubleClick事件的复选框发生了:

If you just want to know a DoubleClick event occurred from the CheckBox:

private void TreeViewDoubleClick(object sender, EventArgs e)
{
    var localPosition = treeView.PointToClient(Cursor.Position);
    var hitTestInfo = treeView.HitTest(localPosition);
    if (hitTestInfo.Location == TreeViewHitTestLocations.StateImage) 
        return;

    // ... Do whatever other processing you want
}