Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Visual Basic .NET (http://www.programmingforums.org/forum19.html)
-   -   Dragging and Dropping (http://www.programmingforums.org/showthread.php?t=13504)

mattireland Jul 8th, 2007 12:16 PM

Dragging and Dropping
 
Hi,

I'm wanting to create a drag and drop of picture frames. If I like have one picture frame and I want a Message Box to come up when it is positioned over the other Picture Box. Could someone please upload a project showing me how to do this or just the code if the picture boxes are called PBox1, PBox2 e.t.c.

Many thanks!

Matt Ireland

melbolt Jul 9th, 2007 8:07 AM

http://www.vb-helper.com/howto_net_drag_drop.html

I doubt anyone will create a project and do all the coding, but you could use the example provided above and modify it.

Besides the only way to learn is to do it yourself.

mattireland Jul 9th, 2007 11:54 AM

Yeh - thanks. It was a bit stupid of me to get someone to do it for me. It takes all the fun out after all! I'll have a look and see how I get on. Thanks again for the link!

melbolt Jul 9th, 2007 12:24 PM

you might want to think twice about putting your email address in your sig, a spambot will eat that up.

mattireland Jul 9th, 2007 1:07 PM

Thanks for the advice. It's just I like people emailing me.

That must be why I've got increased spam. I'll monitor the sources.

Thanks!

beni_dude Apr 15th, 2008 4:35 PM

Re: Dragging and Dropping
 
Can you find an drag and drop example of any control (in my case it text box or label) but in C#

Thanks

mattireland Apr 16th, 2008 2:19 AM

Re: Dragging and Dropping
 
http://www.codeproject.com/KB/cs/dandtutorial.aspx

or

http://www.java2s.com/Code/CSharp/GU.../Drag-Drop.htm


Any help?

Matt. I

beni_dude Apr 16th, 2008 5:13 AM

Re: Dragging and Dropping
 
Thanks friend I will check out and let you know if it did the trick

beni_dude Apr 16th, 2008 10:55 AM

Re: Dragging and Dropping
 
Hey
Sadly I'm such a newbie that I couldn't use those examples (even when I tried to do it one by one).

What I'm trying to do is very simple, I want to be a able do drag and drop a control (label) in my form.

In the propriety of the form I enabled the allowDrag to true (I'm not sure what should be enable so I enabled the both the form and the control).

Now I want on the event of enter (I think that the right event that I need to catch, I'm looking for the event that starts when I press on the control) I want to give the the control the same location of the mouse (with its X&Y locations) and here lies the problem.

Let add me code:
Quote:

point p = new point(0, 0);

p.x = MousePosition.X;
p.y = MousePosition.Y;
//Here is the problem
label1.Location.X =p.x;
label1.Location.Y = p.y;
I created an point class that do receive the mouse location (I checked it out when I debugged) but when I try to set the control location (the label) I get this error message:

Quote:

Cannot modify the return value of 'System.Windows.Forms.Control.Location' because it is not a variable
I understand what the error message mean but I still don't know how to set the location?!

lectricpharaoh Apr 16th, 2008 4:03 PM

Re: Dragging and Dropping
 
This probably should have been in a new thread, beni, but since it's here...

Having your control, form, etc recognize drag-and-drop just means it will be alerted when the user tries to drag something onto it from somewhere else while it's running. As an example, imagine you have some picture-viewing software such as PMView running, and you drag an image file onto the program's window. It can then open up the file. WinZip can receive drag-and-drop notifications, and will respond by adding those files to an archive.

Now, it seems what you're talking about is dragging controls onto a form while you're designing it. This is something different, and you don't need to adjust any of your control properties to allow this; rather, it's how a visual forms designer works. You can drag controls onto your form, move them around, and (depending on the control) resize them.

Are you using the full version of Visual Studio? If so, what version? If not, what are you using? Perhaps you're using one of the express editions you can download free from Microsoft.


All times are GMT -5. The time now is 10:39 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC