CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Aug 2001
    Posts
    4

    Trouble with TreeView Control (VB6)

    I am attempting to use indeces to go through all the nodes in a TreeView, and save the data. I figured since you could use them to remove nodes, you could refer to the nodes that way as well -- I was wrong.
    *Notes about code:
    -GetIndex takes the text of a given node and asigns to the varible "gottenIndex", the index of the entry of the collection memList, whose "sName" property matches the text of the node. memList is a collection of clsMembers, a Class I wrote, that has fName, lName, sName, Notes, Rank, and Superior.
    Here is the Save code I'm using:


    Public Sub Save_Data()
    Open "C:\test.txt" For Output As #1
    For i = 1 To MemList.Count
    GetIndex (frmMain.tvTreeView(i).Text) ' won't work b/c TreeView doesn't take an index unless it's trying to remove an item
    Select Case MemList(gottenIndex).Rank
    Case "King":
    Write #1, frmMain.tvTreeView(i).sName
    Case "Governor":
    Write #1, vbTab & frmMain.tvTreeView(i).sName
    Case "Officer":
    Write #1, vbTab & vbTab & frmMain.tvTreeView(i).sName
    Case "Countryman":
    Write #1, vbTab & vbTab & vbTab & frmMain.tvTreeView(i).sName
    End Select
    Next i
    Write #1, "//"
    For i = 1 To MemList.Count
    Write #1, MemList(i).fName, MemList(i).lName, MemList(i).sName, MemList(i).Notes, MemList(i).Rank, MemList(i).Superior
    Next i
    Close #1
    End Sub


    The output should look something like this( sans the "=" signs:
    =================================
    Joe
    Tom
    Harry
    Pete
    //
    First,Last,Joe,Notes,King,
    First,Last,Tom,Notes,King,
    First,Last,Harry,Notes,Governor,Tom
    First,Last,Pete,Notes,Governor,Tom
    ====================================
    Hope you can help...

    Thanks in advance,
    Pete "Cousin Sammy" Michaud


  2. #2
    Join Date
    Aug 2001
    Posts
    4

    Re: Trouble with TreeView Control (VB6)

    Notes about that file format:

    Joe
    Tom
    Harry 'this should be tabbed
    Pete 'this should be tabbed
    //
    First,Last,Joe,Notes,King,
    First,Last,Tom,Notes,King,
    First,Last,Harry,Notes,Governor,Tom
    First,Last,Pete,Notes,Governor,Tom



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured