Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I know how to draw a line on a form but I don't know how to make that graphic drag able in a panel and if the graphic touches something like a control in that panel something will happen for example.


C#
draw graphic = Gr

panel1 mouse_move
{
if (mouse = down)
Gr = mouse.X.Y
}

Gr_Move
{
if (Gr.contains(label1)
{
msgbox.show("Hey You got me!")
}
}


its not proper code, not really code at all, but thats just how i want to to work out, its kinda like the drag with a picturebox but this is with the graphic, can anyone please help me construct this? I do have a picurebox version of this with-out the drawn graphic.
Posted

1 solution

Hi,

You need to keep a list of all the interactive objects which contains the x, y, width and height or left, right, top and bottom positions. The System.Drawing.Rectangle object does both.

The following is a simple drag and drop tutorial which will show you how to drag an image.

A Simple Drag And Drop How To Example[^]

You'll need to extend this to check, whilst dragging, if the edges of the image overlap with any of the interactive controls.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900