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

Treeview control questions

Status
Not open for further replies.

foxprogram

Programmer
Aug 31, 2004
28
0
0
HU
I use treeview control on my form.
I don't know exactly how does it work :(

I would like to use this control to let the user to choose items from the treeview control.

Than I would like to check which items are checked by the user.
Now I did the follows:
- added treeview control
- load values into the tree
- user able to select items
(ThisForm.oleTreeView.Checkboxes=.t.)

Now I should know which items are selected.
It should be like this (but this ex. not works):


If ThisForm.oleTreeView.Nodes.Count > 0
For Each loNode In ThisForm.oleTreeView.Nodes
IF thisform.oletreeView.Nodes.Item.Checked
MESSAGEBOXthisform.oletreeView.selectedItem.Key)
ENDIF

EndFor
EndIf


Anybody could help me, please ?

Thank you
 
Not sure how to do it with a FOR...EACH, but with a FOR...NEXT you can do it this way:
Code:
If ThisForm.oleTreeView.Nodes.Count > 0
   FOR zzz = 1 TO ThisForm.oleTreeView.Nodes.Count 
      IF ThisForm.oleTreeView.Nodes.Item(zzz).Checked
          MESSAGEBOX(ThisForm.oleTreeView.Nodes.Item(zzz).Key)
      ENDIF
   NEXT
ENDIF

-Dave Summers-
[cheers]
Even more Fox stuff at:
 
Try,
Code:
If ThisForm.oleTreeView.Nodes.Count > 0
    For Each loNode In ThisForm.oleTreeView.Nodes
        IF [red]loNode[/red].Item.Checked 
           MESSAGEBOX[red]([/red]thisform.oletreeView.selectedItem.Key)
        ENDIF
    EndFor
EndIf
Rick

 
Yet another question.
How should I do the simpliest way that if I check a node in the treeview, all of its own children let to checked or unchecked ?
 
In the Treeview.NodeCheck event i did:
--------------------------------------

If lapozo.oleTreeView.Nodes.Count > 0
FOR zzz = 1 TO lapozo.oleTreeView.Nodes.Count
IF thisform.getnodetext(lapozo.oleTreeView.Nodes.Item(zzz).Parent)=Node.Text
IF lapozo.oleTreeView.Nodes.Item(zzz).Checked
lapozo.oleTreeView.Nodes.Item(zzz).Checked=.f.
ELSE
lapozo.oleTreeView.Nodes.Item(zzz).Checked=.t.
ENDIF
endif
Next zzz
Endif

It is working fine, but only for one level lower...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top