473,566 Members | 2,772 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 QueryContinueDr ag 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 QueryContinueDr ag 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 2264

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

Similar topics

0
1734
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 control. The operation takes place entirely within this single control. There is no need to provide for interaction with other controls, forms,...
1
2533
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 which people advise that this process is no different the intra-application drag-n-drop process. I've had no luck with this concept. In fact,...
6
4915
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. However, either it only add it to the root level or it only add it on level below, doesn't matter what I select. And in some case, I just get an...
3
1404
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 sub-class ? If no, any related information/reference ? Thanks a lot
3
2779
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
3776
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 target node in the treeview and auto expand it if applicable... but after a fair bit of head scratching I can't find any easy way to accomplish this. ...
0
349
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 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...
3
10578
by: VB Programmer | last post by:
In VB.NET 2005 (winform) any sample code to drag & drop items between 2 listboxes? Thanks!
1
1862
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
7666
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
0
7584
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7888
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8108
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7951
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2083
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1201
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
925
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.