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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tree View - Next Steps 1

Status
Not open for further replies.

Scott24x7

Programmer
Jul 12, 2001
2,826
JP
So I have the tree view populating as I would like, it nicely displays the complex relationships between my tables, and I can see the relevant info for the node that I want to show. Very cool.
I thought the next step would be straight forward, but now I'm finding it isn't.

So what I would like to do next is have a "Expand All/Collapse All" function (which I can use to expand actually all or just the full branch of some root node, or any nodes below in a branch that I'm in.)

I see there are "Expand" and "Collapse" events, but when I tried a call like:

This.Treeview1.Expand(1) (expecting this would at least "open" the first node in the tree), it didn't...

I tried a few other things but none of them worked. And I can't find a good example that seemed to show how to even open a single node.

So what's the best way to go about this? I did put a button over the top of the tree called "Expand All" (which also switches to "Collapse All once its been pressed), but I've not been able to get the nodes to expand or collapse from within or outside the control. Any suggestions?
Many thanks.


Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
These are events, not methods :)
If you want to expand some node:
Code:
 This.Treeview1.Nodes(1).Expanded = .t.

Borislav Borissov
VFP9 SP2, SQL Server
 
Scott, remember I was telling you about the Nodes collection? Well, you can loop through all the nodes, setting the Expanded property of each one to .T. or .F., as appropriate:

Code:
FOR EACH loNode IN this.nodes
  loNode.Expanded = .T.    && expands all nodes
ENDFOR

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Scott, it occurs to me that you should invest a few minutes of your time in learning to use the VFP Object Browser. This will give you a lot of information about the Treeview, or any of the other ActiveX controls or COM objects on your system:

1. Open the Object Browser from the Tools menu.

2. Click the "Open type library" button; select the COM Libraries page; scroll down to "Microsoft Treeview Control 6.0"; check the adacent box; click OK.

3. In the left-hand pane, drill down to Classes. Then drill down to either Treeview, Node or Nodes (or any other class you might be interested in).

4. In the right-hand pane, drill down into either Properties, Events or Methods, as appropriate.

You will now see all the properties, etc. for the relevant object, along with helpful information in the bottom pane.

For example, if you drill-down to Node, then select Properties, then Expanded, the bottom pane will tell you that Expanded is of type Logical (so you can set it to .T. or .F.), and that it "Returns/sets a value which specifies if a Node object is expanded.". The "returns/sets" is important, because it tells you that this particular property is not read-only.

In the case of events and methods, the helpful text tells you what parameters are passed and what the type of the returned value is.

I use this tool quite often when working with ActiveX controls - and especially when trying to answer questions about them in the forum.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro articles, tips and downloads
 
Hi Mike and Boriss,
Thanks so much for that. I had tried various combinations of setting Expanded = .T. or passing a (<node#>) to the expression, but I see now from both of these examples where that went wrong.

Also, thanks for the refresher on the Object Browser. I had totally forgotten about it. Though it's a little cryptic still, it's better than running off Intellisense to try to see what PEMs are available at each object point. (I still would have gotten this Expand usage wrong though, in fairness). So I get it now, let me go back to beating on this control, and learn a bit more as I play with various usages of expand and collapse!
Cheers

Best Regards,
Scott
ATS, CDCE, CTIA, CTDC

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top