When using the winform standard Treeview control, the following similar nodes are added:
Parentnode1
--- Childnode1
--- Childnode2
Parentnode2
--- Childnode1
--- Childnode2
When parentnode2 is collapsed, double-click parentnode2. The node is automatically expanded and the nodemousedoubleclick event will respond. In response to the nodemousedoubleclick event, the treenodemouseclickeventargs ParameterEThere may be confusion. This is mainly because when you double-click the parent node, the child node is expanded or started by default. When you expand or start the child node, treeview automatically adjusts the display position of the node in the font. If there are many sub-nodes and the position is moved, E. node cannot represent the actual double-click node. For exampleProgram. E. node may be childnode1 or childnode2 when you double-click parentnode2. Different parameters may appear because of different locations.
To solve this problem, we should avoid using E. node in actual programming. Instead, we should use treeviewinfo. selectednode to replace the double-click node. This perfectly solves the problem of double-click event behavior disorder. The following is the double-click event that I actually use.Code.
Code
Private Void Treeviewinfo_nodemousedoubleclick ( Object Sender, treenodemouseclickeventargs E)
{
If (E. Button = Mousebuttons. Right)
Return ;
VaR heatrw = Treeviewinfo. selectednode. Tag As Heatreadwrite;
If (Heatrw ! = Null )
{
Heatwriteform HF = New Heatwriteform (heatrw );
HF. showdialog ();
HF. Dispose ();
}
}