View Single Post
  #3 (permalink)  
Old March 22nd, 2005, 04:59 PM
katsarosj katsarosj is offline
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 540
Thanks: 0
Thanked 4 Times in 4 Posts
Default

The Treeview has a BeforeSelect event where you can place a for...next loop to scan the nodes.
You can get the parent by using e.Node.Parent (as Brian stated) which is passed in the Treeview arguments. You can look for a checked child like this:

If e.Node.Nodes.Count >= 1 And e.Node.Checked = True Then
     Dim tnode As New TreeNode
     For Each tnode In e.Node.Nodes
         If tnode.Checked Then
             MessageBox.Show("Child is checked.")
             e.Cancel = True 'cancels the check event
             Exit For 'exit the loop when one is found
         End If
     Next
End If


This should get you started, but as Brian said it needs to be recursive in order to scan nodes deeper than 1 level.

J

P.S. - Pinoy means Filipino.
Reply With Quote