Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Treeview Check Boxes 1

Status
Not open for further replies.

ProjectExplorer

Programmer
Mar 22, 2002
95
GB
I have added a treeview activeX object to my form and selected the checkbox option letting the user select multiple nodes.

I am however, struggling to find code which enables me to determine which nodes have been selected upfront before I action each selection.

Can any one direct me to a web page or provide an example to illustrate how this can be achieved.

Any help appreciated.

Thanks
 
The following example assumes that the name of the Tree control is "xTree". It will display the names (text) of each node that was checked. To test it out, place a command button on your form and in the OnClick event, insert the following code.

Dim i As Integer

For i = 1 To xTree.Nodes.Count
If (xTree.Nodes(i).Checked) Then MsgBox xTree.Nodes(i).Text & ": " & xTree.Nodes(i).Checked
Next i
 
FancyPrairie

Many thanks for the code. Works perfectly and will be very useful.

Thames
 
FanciePrarie

Out of interest, do you have a source for this code(book, website etc). I have found treeview info spread around (MSDN) and bits and peices on various sites but have yet to come across a definitive guide.

Thanks
 
No I haven't, but what I did, to make things easier was to declare a variable as TreeView and then used debug's Local Window view to see what the object looked like. Also, since the object is declared, when you type the name of the object followed by a period, Access displays the various properties and methods from which to choose.

For example,

Dim objTree as TreeView
 
FancyPrairie

Good tip, I didn't think about exposing the object model. I suppose this is a good starting point generally.

Many thanks for your help.
 
Only one thing what do I type into the debug Local Window to expose the object model?

 
Debug's Local Window should show the object (debug's Immediate Window is where you type stuff).

Try this...place a command button on your form and in the OnClick event, add the following code (assuming the name of your TreeView control is "xTree")

Dim objTree as TreeView

Set objTree = Me!xTree.Object

Stop

Now you should see objTree in the Local Window
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top