Solved

Scrolling Access Treeview

Posted on 2006-07-08
9
667 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
ID: 17065504
Check your property sheet and see if the Scroll property is set to yes.
0
 

Author Comment

by:dwood1112
ID: 17065545
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
ID: 17065597
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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

Author Comment

by:dwood1112
ID: 17065943
Thanks I tried the suggestion (several ways) but I couldn't get it to work.
0
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 250 total points
ID: 17066151
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
ID: 17066331
Thanks...I'll give it a try
0
 

Author Comment

by:dwood1112
ID: 17068928
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
ID: 17068940
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
ID: 17068960
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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

837 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