Microsoft KB Archive/262520

= BUG: eVB: NodeClick Event Fires First Time TreeView Gets Focus =

Article ID: 262520

Article Last Modified on 10/15/2002

-

APPLIES TO


 * Microsoft eMbedded Visual Basic 3.0

-



This article was previously published under Q262520



SYMPTOMS
When you have a project that contains the Microsoft Windows CE Toolkit for Visual Basic TreeView control, the first time the control gets focus, the NodeClick event fires.



RESOLUTION
To work around this problem, you can set a flag in the Form_Load event. Then, the first time the NodeClick event fires, which is the first time the TreeView control gets focus, you need to clear the flag. Replace the code in the sample under &quot;Steps to Reproduce Behavior&quot; later in this article with the following: Option Explicit Dim bFirstTime As Boolean

Private Sub Form_Load bFirstTime = True TreeViewCtl1.Nodes.Add, , , &quot;Test&quot; End Sub

Private Sub TreeViewCtl1_NodeClick(ByVal Index As Long) If Not bFirstTime Then List1.AddItem &quot;NodeClick&quot; Else bFirstTime = False End If End Sub



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
 Open Microsoft eMbedded Visual Basic 3.0. Create a new Windows CE project. Form1 is created by default. On the Project menu, click to select Components, and then click to add the Microsoft CE TreeView Control 3.0. Add a Listbox and TreeView control to Form1.  Paste the following code into Form1: Option Explicit Dim bFirstTime As Boolean

Private Sub Form_Load TreeViewCtl1.Nodes.Add, , , &quot;Test&quot; End Sub

Private Sub TreeViewCtl1_NodeClick(ByVal Index As Long) List1.AddItem &quot;NodeClick&quot; End Sub  Run the project and tab to the TreeView control. The expected behavior is that nothing has been added to the Listbox, but note that NodeClick has been added, indicating that the NodeClick event has been fired.

NOTE: If the TreeView control has TabIndex = 1, then the NodeClick event fires when the form is loaded.</li></ol>

<div class="references_section">