Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Moving object @ runtime
Message
From
04/01/2007 00:05:56
 
General information
Forum:
ASP.NET
Category:
Forms
Environment versions
Environment:
C# 2.0
Miscellaneous
Thread ID:
01181851
Message ID:
01182094
Views:
10
This message has been marked as a message which has helped to the initial question of the thread.
Hey Einar,

Since you've done some drag and drop already, you probably already know this, but I'll post it anyway.
private Control PickedUpControl;

private void DragControl_MouseDown(object sender, System.MouseEventArgs e)
{
	this.PickedUpControl = (Control)sender;
	this.PickedUpControl.DoDragDrop(sender, DragDropEffects.Move);
}
private void TargetArea_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
{
	e.Effect = DragDropEffects.All;
}
private void TargetArea_DragDrop(object sender, System.Windows.Forms.DragEventArgs e)
{
	this.TargetArea.Controls.Add(this.PickedUpControl);
	Point xy = this.TargetArea.PointToClient(new Point(e.X, e.Y));
	this.PickedUpControl.Location = xy;
}
It's a lot easier than doing drag/drop with TreeView or ListView Items, that's for sure! <g>

(and since it would be nice to have the snap-to-grid and snap-to-somethingelse features) maybe M$ has made some of these things available.

There probably is something ... but unfortunately since I haven't had to use this type of UI I've never researched it. Maybe someone else will pipe in with an opinion. =0)

~~Bonnie


>Thanks for your reply.
>I have done a lot of drag and drop stuff within treeviews and within listviews and between treeviews and listviews and between listviews and treeviews. This is kind of a fun little side project for me so I will not be focused on this 100%.
>
>One thought that struck me was that since what I am trying to do is so similar to the form designer (and since it would be nice to have the snap-to-grid and snap-to-somethingelse features) maybe M$ has made some of these things available.
>
>Einar
>
>>Yeah, you need to look at drag/drop events. It's a bit complicated, but once you understand it, it's not too bad. At one time I was going to put together some sample code to show how it works ... I started, but I never got around to finishing it. If I get some free time later today, maybe I'll see about doing that.
>>
>>~~Bonnie
>>
>>
>>>I have started looking into creating an app where the user can move around objects on the form at runtime. Kind of like the form designer, only I have a relatively small amount of objects to choose from when adding object and later moving them.
>>>Has anyone else here done something similar to this?
>>>Any article or book reference would be greatly appreciated.
>>>
>>>Currently I am using the MouseUp event to click annd drag the object to a new location but I know I know I need to start looking at a different method of moving the objects.
Bonnie Berent DeWitt
NET/C# MVP since 2003

http://geek-goddess-bonnie.blogspot.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform