Microsoft KB Archive/172286: Difference between revisions

From BetaArchive Wiki
(importing KB archive)
 
m (Text replacement - """ to """)
 
Line 58: Line 58:
Use the Clear method to remove all nodes in a TreeView control.<br />
Use the Clear method to remove all nodes in a TreeView control.<br />
<br />
<br />
This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to the &quot;Building Applications with Microsoft Access 97&quot; manual.
This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to the "Building Applications with Microsoft Access 97" manual.


</div>
</div>
Line 86: Line 86:
         Name: btnFillTreeView
         Name: btnFillTreeView
         Caption: Fill TreeView
         Caption: Fill TreeView
         Width: 1&quot;
         Width: 1"
         Height: .25&quot;
         Height: .25"
                         </pre></li>
                         </pre></li>
<li><p>Set the OnClick property of the command button to the following event procedure:<br />
<li><p>Set the OnClick property of the command button to the following event procedure:<br />
Line 101: Line 101:
             ' Add Node objects
             ' Add Node objects
             ' First node with 'Root1' as text.
             ' First node with 'Root1' as text.
             Set nodX = .Nodes.Add(, , &quot;r1&quot;, &quot;Root1&quot;)
             Set nodX = .Nodes.Add(, , "r1", "Root1")
             ' Second node on root with 'Root2' as text
             ' Second node on root with 'Root2' as text
             Set nodX = .Nodes.Add(, , &quot;r2&quot;, &quot;Root2&quot;)
             Set nodX = .Nodes.Add(, , "r2", "Root2")
             ' This next node is a child of Node 1 (&quot;Root&quot;).
             ' This next node is a child of Node 1 ("Root").
             Set nodX = .Nodes.Add(&quot;r1&quot;, tvwChild, &quot;child1&quot;, &quot;Child&quot;)
             Set nodX = .Nodes.Add("r1", tvwChild, "child1", "Child")


           End With
           End With
Line 117: Line 117:
         Name: btnDeleteAllNodes
         Name: btnDeleteAllNodes
         Caption: Clear TreeView
         Caption: Clear TreeView
         Width: .25&quot;
         Width: .25"
         Height: 1&quot;
         Height: 1"
                         </pre></li>
                         </pre></li>
<li><p>Set the OnClick property of the command button to the following event procedure:<br />
<li><p>Set the OnClick property of the command button to the following event procedure:<br />
Line 134: Line 134:
== REFERENCES ==
== REFERENCES ==


For more information about nodes in the TreeView control, search the Help Index for &quot;node object.&quot;
For more information about nodes in the TreeView control, search the Help Index for "node object."


</div>
</div>

Latest revision as of 11:05, 21 July 2020

Knowledge Base


ADT/ODE: How to Remove All Nodes from TreeView Control

Article ID: 172286

Article Last Modified on 1/20/2007



APPLIES TO

  • Microsoft Access 95 Standard Edition
  • Microsoft Access 97 Standard Edition
  • Microsoft Office 97 Developer Edition
  • Microsoft Access Developer's Toolkit 1.1



This article was previously published under Q172286

Advanced: Requires expert coding, interoperability, and multiuser skills.


SUMMARY

The Microsoft TreeView control version 5.0 ships with Microsoft Office 97 Developer Edition.

Use the Clear method to remove all nodes in a TreeView control.

This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to the "Building Applications with Microsoft Access 97" manual.

MORE INFORMATION

The following example demonstrates creating a TreeView control, adding nodes, and then removing the nodes:

  1. Start Microsoft Access and open a new, blank database.
  2. Open a new form in Design view.
  3. On the Insert menu, click ActiveX Control (or click Custom Control if you are using Microsoft Access 7.0).
  4. In the Insert ActiveX Control dialog box, select the Microsoft TreeView Control, and then click OK.
  5. Set the following properties of the TreeView Control:

            TreeView Control
            ----------------
            Name: tvcExample
            Width: 2
            Height: 2
                            
  6. Add a command button to the form, and set the following properties:

            Command Button
            ----------------------
            Name: btnFillTreeView
            Caption: Fill TreeView
            Width: 1"
            Height: .25"
                            
  7. Set the OnClick property of the command button to the following event procedure:

           Private Sub btnFillTreeView_Click()
    
              Dim nodX As Node    ' Declare Node variable.
    
              With Me!tvcExample
    
                ' Set Treeview control properties.
                .LineStyle = tvwRootLines  ' Linestyle 1
                ' Add Node objects
                ' First node with 'Root1' as text.
                Set nodX = .Nodes.Add(, , "r1", "Root1")
                ' Second node on root with 'Root2' as text
                Set nodX = .Nodes.Add(, , "r2", "Root2")
                ' This next node is a child of Node 1 ("Root").
                Set nodX = .Nodes.Add("r1", tvwChild, "child1", "Child")
    
              End With
    
           End Sub
                            
  8. Add another command button to the form and set the following properties:

            Command Button
            -----------------------
            Name: btnDeleteAllNodes
            Caption: Clear TreeView
            Width: .25"
            Height: 1"
                            
  9. Set the OnClick property of the command button to the following event procedure:

            Private Sub btnDeleteAllNodes_Click()
               Me!tvcExample.Nodes.Clear
            End Sub
                            
  10. Switch to Form view and click Fill TreeView; then click Clear Treeview, and note that all nodes are removed.


REFERENCES

For more information about nodes in the TreeView control, search the Help Index for "node object."


Additional query words: basic delete

Keywords: kbhowto kbprogramming KB172286