The information in this article applies to:
SYMPTOMSThe 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
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.
STATUSMicrosoft 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. MORE INFORMATION
When the current node of a TreeView control is touched using the mouse, the
SelectedItem property is updated after the NodeClick event. When the node
is modified by using the keyboard, SelectedItem is updated before the
NodeClick. This makes it difficult to execute code based on the Node object
because a different object will be passed to the NodeClick event depending
on whether the mouse or keyboard was used to generate the NodeClick. For
example, if the intent of the code in the NodeClick event should be fired
only when a new node is clicked upon, the following line of code will work
fine if the mouse is used, but will not work if a user changes the selected
node with the keyboard:
Steps to Reproduce
Additional query words: kbVBp400bug kbVBp500fix kbVBp kbdsd kbDSupport kbControl
Keywords : kbGrpVB |
Last Reviewed: January 5, 2000 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |