Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / November 2006

Tip: Looking for answers? Try searching our database.

drag and drop issue...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lloyd Dupont - 24 Nov 2006 03:44 GMT
If I use software like OpenOffice and try to drag text I could notice that
1. when I drag inside the document I'm moving the text
2. when I drag outside the document I'm copying the text

Yet it all looks like one smooth operation. With correct cursor feedback
(the little + marker next to the icon).
My problem is, once I call DoDragDrop() it's blocking, I have no other
opportunities to change the AllowedEffect to only Copy if I drag over, say,
an other control

And QueryContinueDrag:
1. don't allow me to change the efect
2. don't inform me about the current drop target

How could I do that?
(i.e. how could I modify the allowed efffect depending on the target (i.e.
wether it's me or not))
Ciaran O''Donnell - 24 Nov 2006 09:42 GMT
The DragDropEffects enum is a Flags enum so when DoDrapDrop'ing at the
source, if the data can be moved or copied then you set the effect to
DragDropEffects.Copy | DragDropEffects.Move
The when the destination handles drag enter, that can decide whether it
should be copied or moved to it.
I generally like to make a struct or class to hold more information that the
dragdrop'd data like the source object and anythign else used in the
descision. Then if dragging to another part of my app then i can handle it
easily.

HTH

Ciaran O'Donnell

> If I use software like OpenOffice and try to drag text I could notice that
> 1. when I drag inside the document I'm moving the text
[quoted text clipped - 13 lines]
> (i.e. how could I modify the allowed efffect depending on the target (i.e.
> wether it's me or not))
Lloyd Dupont - 24 Nov 2006 13:31 GMT
No, it didn't H!

Perhaps I was not clear enough?
I'm trying to do something which looks impossible with the public .NET API,
yet Word and OpenOffice manage it.

In pseudo code it will look like that:

if(target == this)
   AllowedEffect = Copy | Move;
else
   AllowedEffect = Copy;

Of course the source should update the AllowedEffect every time the target
change. Which is not possible with the API, yet Word manage to do it.
So I wonder how it does it...

> The DragDropEffects enum is a Flags enum so when DoDrapDrop'ing at the
> source, if the data can be moved or copied then you set the effect to
[quoted text clipped - 31 lines]
>> (i.e.
>> wether it's me or not))
Jeff Gaines - 24 Nov 2006 15:18 GMT
On 24/11/2006 in message <##xYcz8DHHA.3520@TK2MSFTNGP04.phx.gbl> Lloyd
Dupont wrote:

>No, it didn't H!
>
>Perhaps I was not clear enough?
>I'm trying to do something which looks impossible with the public .NET
>API, yet Word and OpenOffice manage it.

I do that with a TreeView as follows:

private void tvFav_DragOver(object sender, DragEventArgs e)
{
    //    Control key moves
    if (e.Data.GetDataPresent(typeof(JExLVItem)))
    {
        if ((e.KeyState & 8) == 8)
            e.Effect = DragDropEffects.Move;
        else
            e.Effect = DragDropEffects.Copy;
    }
    else
        e.Effect = DragDropEffects.None;
}

Can you trap DragOver in whatever control you are dropping on? You could
then test for the type of data.

Signature

Jeff Gaines

Dave Sexton - 26 Nov 2006 05:53 GMT
Hi Lloyd,

The key is that your drop targets must be aware of the source, not the other
way around.

You may want to read the following article:

"Performing Drag and Drop Operations"
http://msdn2.microsoft.com/en-gb/library/ms973845.aspx

(The article uses VB.NET; sorry :)

Signature

Dave Sexton

> No, it didn't H!
>
[quoted text clipped - 49 lines]
>>> (i.e.
>>> wether it's me or not))

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.