Solved

Scrolling Access Treeview

Posted on 2006-07-08
9
664 Views
Last Modified: 2012-06-27
I'm using the Northwind code on my projects Treeview and it is working well....But I cant scroll if the item is above or below the visible boundry...I've searched the comments and it looks like .EnsureVisible on DragOver is the way to go, but I'm not having much success...

I'm using the following code:

Private Sub xTree_OLEDragOver(Data As Object, Effect As Long, _
        Button As Integer, Shift As Integer, x As Single, y As Single, _
        State As Integer)
    Dim oTree As TreeView

    'Create a reference to the TreeView control.
    Set oTree = Me!xTree.Object
   
    'If no node is selected, select the first node you dragged over.
   
       If oTree.SelectedItem Is Nothing Then
        Set oTree.SelectedItem = oTree.HitTest(x, y)
    End If

    'Highlight the node being dragged over as a potential drop target.
    Set oTree.DropHighlight = oTree.HitTest(x, y)
End Sub

Can anyone help me figure out how to wrap .EnsureVisible into this??

Lost in the forest
0
Comment
Question by:dwood1112
  • 5
  • 2
  • 2
9 Comments
 
LVL 11

Expert Comment

by:BillPowell
Comment Utility
Check your property sheet and see if the Scroll property is set to yes.
0
 

Author Comment

by:dwood1112
Comment Utility
The scroll property is set to yes....As far as I can tell, this just adds a scroll bar...not much use during D&D
0
 
LVL 11

Assisted Solution

by:BillPowell
BillPowell earned 250 total points
Comment Utility
Im not sure but you could try something like this: (completely untested)

Dim nodCurrent As Node
Set nodCurrent = oTree.SelectedItem
nodCurrent.EnsureVisible = True

Hopefully someone more versed in this drag and drop with Treeview will ring in.
0
 

Author Comment

by:dwood1112
Comment Utility
Thanks I tried the suggestion (several ways) but I couldn't get it to work.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 250 total points
Comment Utility
Did you try the HitTest for your .EnsureVisible:

Set oTree.SelectedItem = oTree.HitTest(x, y)

Otherwise, I don't know how you can do this ... the builtin MS treeview is pretty limiting in many regards.
0
 

Author Comment

by:dwood1112
Comment Utility
Thanks...I'll give it a try
0
 

Author Comment

by:dwood1112
Comment Utility
OK....I finally got it to work with the code below...at least it scrolls down...still working on getting it to scroll back up. Thanks for your help


 Dim oTree As TreeView
 Dim currentNode As Node
       
 Set oTree = Me!xTree.Object
 Set DropHighlight to the mouse's coordinates.
 Set oTree.DropHighlight = currentNode
 Set currentNode = oTree.HitTest(x, y)
 currentNode.EnsureVisible
0
 
LVL 84
Comment Utility
Good to know ... keep us posted as to your progress, this is something I'd like to include in my sample.
0
 

Author Comment

by:dwood1112
Comment Utility
Revision:

The SetDropHighlight isn't needed. the code below works fine for downward scroll....

 Dim oTree As TreeView
 Dim currentNode As Node
       
 Set oTree = Me!xTree.Object
 Set currentNode = oTree.HitTest(x, y)
 currentNode.EnsureVisible
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now