Node Count returns incorrect value

Summary

Id: 13463.17
Type: Bug Bug
Current Status: Resolved

Detail

15 Dec 2003 Open JBS

If you unload any form which contains a Treeview, and then reopen it, the child-counter doesn´t work anymore.

8 Jan 2004 Resolution Identified Steve McMahon

The cause of this bug is incorrect use of the m_colIDs collection inside the code. In three places it is finding items in the collection by index, rather than by Key, which means the code works first time around but fails on the subsequent attempt. Example in the fCount property of vbalTreeView.ctl:

Friend Property Get fCount(ByVal lID As Long)
Dim iCount As Long
Dim hItem As Long
Dim lErr As Long
Dim rel As Long
   
   On Error Resume Next
   hItem = m_colIDs(lID) <<<
   lErr = Err.Number
   On Error GoTo 0
   If (lErr = 0) Then
      rel = TVGN_CHILD
      Do While Not (hItem = 0)
         hItem = SendMessageL(m_hWnd, TVM_GETNEXTITEM, rel, hItem)
         If Not (hItem = 0) Then
            iCount = iCount + 1
         End If
         rel = TVGN_NEXT
      Loop
      fCount = iCount
   End If
   
End Property

The highlighted line should read

m_colIDs(CStr(lID))
15 Feb 2004 Resolved Steve McMahon

Fixed.