V
V
Vadim Bulgakov2015-10-25 21:08:08
C++ / C#
Vadim Bulgakov, 2015-10-25 21:08:08

How to fix a bug in TreeView?

When a Node is selected and then moved, a situation arises that treeView1.SelectedNode points to the element selected before (that is, in order for everything to go smoothly, you must first click on the entry so that the selection falls on it, and only after that it can be dropped, but you can’t drag it on the fly, because it reads that the entry that was clicked before is selected).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vadim Bulgakov, 2015-10-25
@Silector

I got it)
This had to be done through the HitTest method and the treeView1_MouseMove event

treeView1_MouseMove((object sender, MouseEventArgs e)
        {
            TreeNode n = treeView1.HitTest(e.X, e.Y).Node;
            if(n != null  && e.Button == MouseButtons.Left)
                    treeView1.SelectedNode = n;
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question