Treeview problem (MSCOMCTL) (1 Viewer)

Ronald de Graaf

New member
Local time
Today, 08:44
Joined
Sep 12, 2020
Messages
16
Hi Guys,
I've created a form with 2 Treeview object on it.
I can Drag and Drop from one to the other but I have a problem when drag & drop is finished.

If I Drag and Drop from Treeview_1 to Treeview_2, the vertical scrollbar that was visible in Treeview_1 disappears...

Has anyone an idea how I can get this back visible again? I've already tried with Treeview_1.object.scroll=true but that doesn't work...

Thanks in advance!
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 02:44
Joined
Apr 27, 2015
Messages
6,380
Hello Ronald, @MajP is our resident TreeView expert. I've tagged him in hopes he will see and have some time to assist...
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:44
Joined
May 21, 2018
Messages
8,554
That is very niche problem, that I doubt anyone has ever seen, know how to recreate it, or guess what is the cause. Not many people use Treeviews, fewer enable drag and drop, and very very few ever drag and drop between two trees. I personally have never seen it done, and would be curious of the use case for it.

You will likely have to post the example database, but even then not sure if there is a solution. The Treeview has its quirks and may just be a one of them.
 

Ronald de Graaf

New member
Local time
Today, 08:44
Joined
Sep 12, 2020
Messages
16
Hi MajP,

So why actually use 2 Treeviews...

I'll try to explain.

I have 3 tables.
1. Address
2. Object
3. Inspection

The Treeview is a maximum of 3 levels:
1
1.2
1.2.3
1.2.3
1.2.3

The address is the address of a factory (allways 1 node - the root).
There are more than 1,000 objects at that factory and inspections are carried out among these objects.

Now they want the inspections to be very easy to move. I manage that well within 1 Treeview with Drag&Drop.

It is possible to move an Object to another object so that all inspections are moved to the Object being dropped on.
Or, I can drag and drop an inspection to another object.

However, the Treeview is quite long. If you want to move something at the bottom of the Treeview to the top, it is not really easy.

So I thought, I'll create a 2nd, temporary, Treeview to which the Object or Inspection can be dragged. That also works well.

It also works to just drag an inspection to the 2nd treeview.

So the Drag&Drop between the 2 treeviews works well.

But indeed something strange happens with the 1st Treeview as soon as I move an object to the 2nd Treeview. The vertical scroll bar disappears...

But I have since found out that it can be worked around by expanding a node from the 1st treeview.

The scroll bar will then reappear.


So so far this problem.

But you wonder why I work with 2 Treeviews?
This is because only a mouse is used in the factory. So I thought this would be best done with an object on a form that supports Drag&Drop. In addition, I can quickly show in a Treeview which inspections belong to which object. And with Drag&Drop objects and/or inspections can be moved very quickly to another object.

Of course I am always open to other suggestions. Are there other, perhaps better ways to do this?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:44
Joined
May 21, 2018
Messages
8,554
On my very long lists I implement a double click to select an item and a double click to drop. This avoids dragging and scrolling. On my trees I also put up down arrows on the main form to bubble the node up or move down.
Does the scrollbars reappear if you expand the branch via code?
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:44
Joined
May 21, 2018
Messages
8,554
Have you considered trying to cut and paste. I have code to bring up a right click menu when you right click on a node. The code determines the right clicked node and i can add a cut and paste to that. Then you could right click and "cut" a node. Scroll to where you want and then paste it. I have not tried to code that yet, but I think would be doable if interested.

rightclick.jpg
 

Ronald de Graaf

New member
Local time
Today, 08:44
Joined
Sep 12, 2020
Messages
16
Have you considered trying to cut and paste. I have code to bring up a right click menu when you right click on a node. The code determines the right clicked node and i can add a cut and paste to that. Then you could right click and "cut" a node. Scroll to where you want and then paste it. I have not tried to code that yet, but I think would be doable if interested.

View attachment 104302
Hi MajP,

Thanks for your reply.
It is indeed an option to bring up a right click menu. But, Drag and Drop is much faster.
With a right click menu the user has to click, then select what to do and on another node again right click and select what to do.

My solution uses a second (temporary) Treeview. No database updates are done when a user moves a node to the 2nd Treeview. Only when a node is moved back (to another position) in the first treeview, the database is updated.

By the way, I'd took a look at your solution already. Looks good but as said before I think Drag&Drop is faster...
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:44
Joined
May 21, 2018
Messages
8,554
Not suggesting to remove the drag and drop, but to add cut and paste for long lists.
The two trees seems cumbersome and excessive. You have to drag to second list, then scroll first list, then drag from second to first. Pretty sure cut and paste is faster an fewer mouse operations.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:44
Joined
May 21, 2018
Messages
8,554
But, Drag and Drop is much faster.
I doubt it. IMO cut and paste is simpler and likely much faster for a large list where you are moving nodes outside of the visible area. I would have to see the two tree approach, but does not sound simpler or quicker from the explanation.

Open the large tree.
1. Right click and expand the first branch. This takes some time. There are 10K total nodes so assume about 1k in the first branch. More than enough to exceed the visible window.
2. Scroll to the very bottom and right click to select and cut a node.
3. Scroll to top of the list and right click to paste it.

In fact I do not know how to do this without cut and paste. I know of no way to make the treeview scroll as you drag. So I know of no way to drag and drop outside of the visible window. However, you can drag and drop in the visible window.
 

Attachments

  • MajP TreeviewDemo v19_Full_CutPaste.accdb
    1.5 MB · Views: 116

Ronald de Graaf

New member
Local time
Today, 08:44
Joined
Sep 12, 2020
Messages
16
Hi MajP,

I don't quite agree with you though.

I have sent 2 screenshots where it might be clearer.

3 nodes are moved from the 1st treeview to the 2nd, temporary, treeview. These 3 nodes have to be moved far down. I now put them with Drag&Drop in the 2nd treeview

tv1.png


Then I search in the 1st treeview for the Object where the 3 nodes have to go.
Then I move the 3 nodes from treeview 2 to the new (already existing) nodes in treeview 1

tv2.png
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 02:44
Joined
May 21, 2018
Messages
8,554
I was only envisioning movement of nodes would be rare, and it would be one at a time. I did not think about this case where you want to move more than one node (and children) to the non visible window. In this case having the two trees would be helpful.
In the above example the scroll bar remains in Tree 1. Did you therefore solve your issue?
How are you dragging and dropping to the second Tree? Are you actually creating a copy of the node and its children when you drop on tree2. When you drop it back on to Tree1 are you then deleting from Tree2 and creating a new node (and children) in Tree1. Any chance you can post this code?
 

Users who are viewing this thread

Top Bottom