[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1360
  • Last Modified:

MS Tree View - manipulation

My Fellow experts, I am working with the Tree View control within an MS Access form.

This tree has various root notes (at the moment we have 6 of them) off of these root nodes we have a number of important immediate child nodes.

The Check box nature of the tree view has been enabled.

What I would like to do is disable checkboxes on two parent nodes (I do know which ones), leaving checkboxes enabled on the 4 remaining parent nodes.

Of the 4 nodes which have check boxes enabled, I then want to disable the check boxes on some (not all) of the child nodes (again, I know which ones).

Is this possible, if so, would you be able to help me with the code.

many thanks
Dave
0
Runrigger
Asked:
Runrigger
2 Solutions
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
I don't think you can enable only SOME of the checkboxes; it's an all or nothing setup.

You could use the Click or Expand event of a Node to determine if you should show Checkboxes, and then toggle the property based on that, but if you have multiple expanded Nodes, this would not be a visually appealing event.

Or you could use a 3rd party control with more functionality that the MS ones.
0
 
RunriggerAuthor Commented:
emmm, not great news but something to work with nonetheless!

As an alternatively, I am display them on all nodes, that's fine, however, where I had originally planned to disable them, I have instead tried to make it so that when they check the box, the code automatically unchecks the box;

Private Sub treeAccounts_NodeCheck(ByVal Node As Object)
    If Left(Node.Key, 4) = "T001" Then Node.Checked = False
End Sub

however, the box always checks anyway (there doesn't not appear to be a way to "cancel" the checking of the box, so this option doesn't work for me either.

Thoughts?
0
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
I haven't used the MS Treeview in quite some time, but it would seem that you would use a different event to fire this - perhaps the Expand, Validate or Click event would be better? Not sure.

Here's the MSDN reference for the Treeview control, in case you don't already have it:
http://msdn.microsoft.com/en-us/library/aa443492(VS.60).aspx
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
RunriggerAuthor Commented:
been there also, as per MS in general their documentation is pretty poor and this doesn't help me any further.

Not sure what to do now as I haven't really learned anything that I didn't already know, do you get the points?

Happy to give them as it confirms that there isn't really anything I don't know, so will stop me exploring any further!
0
 
Helen FeddemaCommented:
It may be that the TreeView control is not the best interface for your needs -- how about using a MultiSelect listbox in place of the nodes that need to be checked?  Perhaps a TreeView could be used for the first level of selection, and then a listbox for the multi-select options.
0
 
Dale FyeCommented:
I played around with it a little bit in one of my apps and came up with this.  When I put the code in the NodeCheck event and stepped through it, I noticed that it was going false, but then went true again on exiting the event, so I assumed that either the Click or MouseUp event was causing it to revert to checked.

Private Sub tree_Activities_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, _
                                                           ByVal x As Long, ByVal y As Long)

    Dim tvw As MSComctlLib.TreeView
    Dim myNode As MSComctlLib.Node
   
    Set tvw = Me.tree_Activities.Object
    If tvw.HitTest(x, y) Is Nothing Then
        Exit Sub
    Else
        'Highlight the node the mouse is over
        Set myNode = tvw.HitTest(x, y)
    End If

    With myNode
        If Left(.Key, 2) = "FY" And .Checked = True Then
            .Checked = False
        End If
    End With
   
End Sub
0
 
RunriggerAuthor Commented:
Helpful, though not entirely what I wanted, thank you guys anyway
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now