Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > VB How-To
|
VB How-To Ask your "How do I do this with VB?" questions in this forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VB How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 23rd, 2006, 04:22 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default TreeView.Nodes(x).Visible & VB6

I have a TreeView control showing a root node per table.
For each of those root nodes I have a list of fields within the table that node represents as the 1st-level children of that root node.

The user drills in, finding the field they’re after, then double-clicks it to add that Table.Field entry to a List Box.

Following that, I want to remove that field from the display of the TreeView, without removing it from the nodes collection.
Following is the code I tried to accomplish this. It does not do what I need; the node stays in the
display, saying “neener, neener, neener!” at me...
Code:
Private Sub tvDBObjects_DblClick()

    On Error GoTo Er

    Dim tv As TreeView  ' Create an early-bound variable
    Dim nd As Node:         Dim ThisItem As Long
    Dim s  As String:       Dim NextItem As Long


    Set tv = tvDBObjects.Object     ' Set a reference to the TreeView
                                    ' in the early-bound variable.
    Set nd = tv.SelectedItem.Parent ' Will raise Error #91 (object 
                                    ' or with block not selected) if
                                    ' this is a root, causing a 
                                    ' graceful exit, taking no action.


    ' Provide for two ListBox conditions: 
    '    1. No data in the ListBox yet;  
    '    2. Already have some data
    s = lstColumns.RowSource
    If s <> "" _
        Then s = s & "; "

    ' Update the List Box.  ColWidths are 0";2.5"
    ' Having the index to the node this datum came
    ' from permits “putting it back” later, if need be.
    ' nd holds the name of the table.
    ' This concat generates:   "##"; "tblName.fld"
    lstColumns.RowSource = s & _
                           """" & tv.SelectedItem.Index & """; """ & _
                           nd & "." & tv.SelectedItem & """"


    ' Assess the situation
    ThisItem = tv.SelectedItem.Index
    NextItem = tv.Nodes(ThisItem).Next.Index


    ' Move the focus
    tv.Nodes(NextItem).Selected = True
    tv.Nodes(ThisItem).Visible = False  ' Expected the node to dissappear 
                                        ' from the tree here
    tv.Refresh   ' Added this stmt;  no help.

Rs:
    Exit Sub

Er: Exit Sub    [green]' Exit Sub will reset the error;  
                ' built-in VB behavior.

End Sub
How can I make this child node disappear, while keeping it in the collection?
What is the intended use of .Nodes(index).Visible?

You can see the behavior I am after in Excel's query builder.
Select a cell, go to the Data menu, and select "Get external data" > "New Database Query..."
 
Old August 28th, 2006, 04:03 PM
Friend of Wrox
 
Join Date: Nov 2004
Posts: 1,621
Thanks: 1
Thanked 3 Times in 3 Posts
Default

Well then (since there are no takers) is there a website (or other nline resource) that really “unpacks”
the functionality of the TreeView control?

(BTW: Found at
Code:
 
       msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcmn98/html/vbprovisiblepropertyactivexcontrols.asp:

         The Visible property of the Treeview control's Node object is read-only at run time.
)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Crystal Report & VB6 & SQL Server wlho VB How-To 2 June 5th, 2013 01:58 AM
How can I go through all child nodes & attribute.. vishnu108mishra C# 1 November 13th, 2007 05:00 AM
TreeView deleting Nodes Apocolypse2005 Beginning VB 6 3 July 11th, 2007 04:16 AM
Migration of treeview from VB6 to VB.NET karveajit General .NET 0 March 27th, 2007 01:34 AM
Migration of Treeview from VB6 to VB.NET karveajit ASP.NET 1.0 and 1.1 Professional 0 March 27th, 2007 01:25 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.