Link to home
Start Free TrialLog in
Avatar of LJG
LJG

asked on

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
ASKER CERTIFIED SOLUTION
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of LJG
LJG

ASKER


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