Article ID: 145681
Article Last Modified on 11/18/2003
APPLIES TO
- Microsoft Visual Basic 4.0 Standard Edition
- Microsoft Visual Basic 4.0 Professional Edition
- Microsoft Visual Basic 4.0 32-Bit Enterprise Edition
This article was previously published under Q145681
SYMPTOMS
The SelectedItem property of the TreeView control is updated at different
times depending on whether the selected node is changed with the mouse or
keyboard.
RESOLUTION
Within the NodeClick event, take into account that the SelectedItem
property may be different depending on the action that caused the NodeClick
event. One method to workaround the specific problem mentioned above would
be to create a private form-level variable and store a reference to the
node each time the NodeClick event is fired. In the example above, this
node can be compared to the Node object passed to the NodeClick event to
determine whether or not the NodeClick is a result of clicking on a new
node. After declaring the form-level variable with this code in the
Declarations section
Private LastNode as Node
the following two lines of code can be used in the NodeClick event to
compare Node objects and exit the subroutine if the same node is still
selected. This code will work for both mouse and keyboard generated events.
If LastNode = Node Then Exit Sub
LastNode = Node
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article. This bug has been fixed in Visual Basic
5.0.
Additional query words: kbVBp400bug kbVBp500fix kbVBp kbdsd kbDSupport kbControl
Keywords: kbbug kbfix KB145681