Try moving the object according to the position of the mouse, and the code below is to collect the path to move the mouse and the place saved in arraylist to get the path that the mouse point moves. U should declare a list of arrays around the world.
private void panel1_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == MouseButtons.Left)
{
ArrayList inList = new ArrayList();
inList.Add(e.X);
inList.Add(e.Y);
list.Add(inList);
}
}
when the user clicks the button, the control should move along the path that the user dragged onto the screen
private void button1_Click_2(object sender, EventArgs e)
{
foreach (ArrayList li in list)
{
pic_trans.Visible = true;
pic_trans.Location = new Point(Convert.ToInt32(li[0]), Convert.ToInt32(li[1]));
pic_trans.Show();
}
}
source
share