Reputation: 10507
So I've seen alot of talk about this on the blog-o-sphere... But I can't tell if it's a bug, or just bizzar behaviour that I don't understand...
Say you have a TreeView
with CheckBoxes
...
Double-click
on a CheckBox
on one of the Nodes
, and then click on the box again... you'll notice that the state doesn't seem to change properly.
Is this a bug
?? I'm always cautious about saying I found a "bug" in .NET
...
Upvotes: 4
Views: 1268
Reputation: 611
I exprerienced similar problem with treeview selection. I had managed Treeview.NodeMouseDoubleClick Event which each node runs with Mouse Double Click and executes different process. But when I double click on treeview (not over the node) code had crashed. I solved the problem when I realized treeview.SelectedNode is not the same one which Treeview.NodeMouseDoubleClick.TreeNodeMouseClickEventArgs e.Node parameter returns.
Thus, if you want to select a node with mouse selection on treeview, you need to click exactly on it.
Hope this helps.
Upvotes: 0
Reputation: 2639
Duplicating the problem shows that this is definitely a bug* (intentional asterisk). Because when you double-click an unchecked check box in a TreeView, then call code like this:
For Each node As TreeNode In Me.TreeView1.Nodes
Console.WriteLine("{0}: {1}", node.Name, node.Checked)
Next
You will find that, while visually it is unchecked, the node thinks it is still checked. I can see a couple things happening:
My conclusion is that somehow, double-clicking is focusing the checkbox which is causing the second mouse click to not be sent to the treenode but it is sent to the checkbox, that is why the checkbox gets unchecked and the treenode is none-the-wiser.
* This is behavior that should not be occurring, how to classify it, I'll leave up to Microsoft.
Upvotes: 5