472,955 Members | 2,526 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,955 software developers and data experts.

TreeView Drag & Drop operation very uncooperative...

Hello everyone,

Yesterday I posted a message about implementing drag & drop in a TreeView
control.

I'm having real difficulty getting this to work -- the process seems to be
incredibly delicately balanced and finding my way through it has descended
into one of those awful situations which I refer to as guess & test.

From the point at which DoDragDrop() function is called until some later
time when the process is completed there is clearly a lot going on in the
background while the .NET drag/drop code takes over the process. For what I
need the dragnode and the dropnode are both TreeNodes in the same TreeView
control. While the process is going on I need to intervene to determine
whether or not dragging a node is allowed and whether or not dropping on the
current 'over node' is allowed and so on.

The difficulties that I'm having can be summarised:

1. The .NET drag/drop code appears to impede other things from ccurring. I
can see how this makes sense but writing debug/confirmation text to the
console (as in: System.Console.WriteLine("msg")) is one thing that can't be
done while dragging is under framework control and this is not helpful.

2. The event ItemDrag fires but neither QueryContinueDrag nor GiveFeedback
fire. The documentation indicates that they are to fire after ItemDrag but
they certainly don't appear to be doing so. The documentation is ambiguous
about whether or not QueryContinueDrag and GiveFeedback fire repeatedly
afterwards but since they don't appear to be firing anyway, I can't figure
that one out.

3. The DragDropEffects object is its own master and seems to have decided
that it doesn't need to pay attention to what I tell it to do. That sounds a
little snotty, doesn't it? -- sorry about that -- it reflects my level of
frustration. Anyway, the effect drops back into DragDropEffects.None (which
gives rise to the "No Parking" cursor) even though I have issued explicit
DragDropEffects.Move or DragDropEffects.Copy.

4. Since I can't change the cursor myself (because GiveFeedback is not
firing) I have resorted to changing the background colour of the nodes to
give visual validity feedback to the user. This works up to a point. As the
cursor moves over nodes I changing the colour to red to say "can't drop
here..." or green to say "...but here is OK". When the cursor moves off a
portential target node I need the background colour to revert to the
'ambient' background to the treeview and this is where things come unstuck.
Changing the colour back causes the underlying code to revert to
DragDropEffects.None and the behaviour is as if dragging is disallowed
altogether. The code to change the colour appears to be independant of
anything the the framework might be doing but obviously it isn't and why
changing the background colour should affect the framework code is pretty
hard to understand.

5. I would happily avoid all of this and implement my own drag code if it
were not for the problem I described in yesterday's post; i.e., The MouseDown
and MouseUp events occur simultaneously even though the physical button has
not been released. Why is this happening?

I'm finding this all very puzzling. There seem to be stumbling blocks in
every direction with this process. Comments and suggestions would be
welcomed. In the meantime I will continue to bang my head against it. This
part of the process always produces a result even if it is just a headache.

--
Kia pai tō haere, e hoa mā!
Nā Plumer
Jul 21 '05 #1
0 2193

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Plumer | last post by:
Hello everyone, I am using MS .NET Framework 1.0 Version 1.0.3705 developing a C# client application using SQL Server on the server side. I am looking to implement drag & drop in a TreeView...
1
by: Kevin Henkener | last post by:
I would like to be able to drag-n-drop System.Windows.Forms.TreeNode objects between two different applications (actually the same application, just two instances of it) in C#. I've seen posts in...
6
by: L.M | last post by:
Hello, I knew how to use the treeview under VB6. After migrating to .NET, well, I'm lost. I try to add a new node, either to the same level or as a child to a selected node in the treeview....
3
by: Kelvin Leung | last post by:
Hi I use Drag and Drop between 2 TreeView Control under VB.Net But I found that it cannot work when I add sub-class for each node Is it drag and drop method cannot work when the node with...
3
by: marc | last post by:
hello, I want to add scrolling and auto expanding after X msec to Drop & Drop in a treeview. Can someone me in the right direction. thanks Marc
3
by: Gary Dunne | last post by:
I'm writing an app that requires drag and drop operation between a ListView and a TreeView control. (The source is the ListView). During the drag drop operation I want to be able to detect the...
0
by: Plumer | last post by:
Hello everyone, Yesterday I posted a message about implementing drag & drop in a TreeView control. I'm having real difficulty getting this to work -- the process seems to be incredibly...
3
by: VB Programmer | last post by:
In VB.NET 2005 (winform) any sample code to drag & drop items between 2 listboxes? Thanks!
1
by: pooja | last post by:
i need to implement drag and drop in treeview in VB. Kindly help. My treeview contains activities maintained using XML Files. Hopefully, Thanks.
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
1
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.