• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 328
  • Last Modified:

Keep values highlighted on two treeviews at the same time

Is it possible to keep values highlighted on two different  Treeviews at once? (I understand from code I know both are picked by the user, but in this problem I'm only talking about what the user sees.)

In the below graphic the user highlighted "Bisson, Terry" on the left treeview control, and then highlighted "Level5-Data2" on the right treeview control.  - They both stay highlighted as the user clicks a button or moves to other controls on a form.  That is what I need to do for a customer.

In reality with two treeviews in Access - when the user highlights  "Bisson, Terry" on the left treeview control, when they  highlight "Level5-Data2" on the right treeview control  "Bisson, Terry" is no longer highlighted on the left.  If they go to another control on the form, neither values are highlighted.

Again this is from the user prospective - what the user sees.

Any help is greatly appreciated.

Thanks in advance for your help.
LJG
TreeView-To-ExpEx5.jpg
0
LJG
Asked:
LJG
2 Solutions
 
Dale FyeCommented:
Try modifying the following two lines of code and putting them in the NodeClick event of the two trees.  Replace "tree_Activities" with the name of each of the trees on your form

    'Highlight the currently selected node
    Me.tree_Activities.DropHighlight = Nothing
    Me.tree_Activities.DropHighlight = Node

These lines cause will highlight the currently selected node in the tree.
0
 
NorieCommented:
This worked for me.
Private Sub tvwOther_NodeClick(ByVal Node As Object)
    tvwOther.DropHighlight = tvwOther.Object.SelectedItem
End Sub

Private Sub tvwBooks_NodeClick(ByVal Node As Object)
    
    tvwBooks.DropHighlight = tvwBooks.Object.SelectedItem
End Sub

Open in new window

Where the two treeviews were tvwOther and tvwBooks.

Did act a bit strange sometimes though.
0
 
LJGAuthor Commented:

Thanks so much for the answers.  I used both snippets to make things work.  Because I'm going to be creating a number of forms with Treeviews, I put some code in a module so that it would be easy to call.  (Some would say that's over coding.)

So --- Create a public function in a module --> TreeView_KeepNodeSelected()

Then call the function on NodeClick event.

For those of you new to controls like treeview, you are going to go to the Treeview control, look at properties, and wonder where the NodeClick event is.  Join the club.

Just go to your code for the form, pick the Treeview from the left pull down, and you will have all your events in the right pull down.  (Same is true for any control)

Hope this helps someone.

Private Sub TreeViewCtl_2_NodeClick(ByVal Node As Object)
	Call TreeView_KeepNodeSelected
End Sub '-------------------------------------------------



Public Function TreeView_KeepNodeSelected() '-------------

Dim ctlTree  As Control
	Set ctlTree = screen.ActiveControl
	ctlTree.DropHighlight = ctlTree.Object.SelectedItem
	
End Function '--------------------------------------------

Open in new window

0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

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