BUG: eVB: NodeClick Event Fires First Time TreeView Gets Focus (262520)



The information in this article 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 "Steps to Reproduce Behavior" later in this article with the following:
Option Explicit
Dim bFirstTime As Boolean

Private Sub Form_Load()
    bFirstTime = True
    TreeViewCtl1.Nodes.Add , , , "Test"
End Sub

Private Sub TreeViewCtl1_NodeClick(ByVal Index As Long)
    If Not bFirstTime Then
        List1.AddItem "NodeClick"
    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.

MORE INFORMATION

Steps to Reproduce Behavior

  1. Open Microsoft eMbedded Visual Basic 3.0.
  2. Create a new Windows CE project. Form1 is created by default.
  3. On the Project menu, click to select Components, and then click to add the Microsoft CE TreeView Control 3.0.
  4. Add a Listbox and TreeView control to Form1.
  5. Paste the following code into Form1:
    Option Explicit
    Dim bFirstTime As Boolean
    
    Private Sub Form_Load()
        TreeViewCtl1.Nodes.Add , , , "Test"
    End Sub
    
    Private Sub TreeViewCtl1_NodeClick(ByVal Index As Long)
        List1.AddItem "NodeClick"
    End Sub
    					
  6. 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.

REFERENCES

261940 BUG: eVB: TreeView: Showing Form on NodeClick Event Displays Form Behind Active Form


Modification Type:MajorLast Reviewed:10/15/2002
Keywords:kbBug kbDSupport KB262520