473,396 Members | 1,836 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 2240

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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

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.