here's the idea:
I have a big picture box contains a map.. let's called it (MAP) and it has 5 country
and 5 small picture boxes each one has a specific city picture on it.
I wanna drag each one of the city's picture and drop it into the right country position in the map..
and if the user drag it to the correct place in the map.. the city's picture will move to the correct basket, otherwise, to the incorrect basket(I didn't how to do this part so I didn't write anything about it in the code)
I think I should use (x,y), but I couldn't do it :(
please explain to me how can I do it?
the code I'm struggle with:
* pictureBox12 is one of city's picture*
* pictireBox3 is the map*
private void pictureBox12_MouseDown(object sender, MouseEventArgs e)
{
CurrentDrag = pictureBox12.AccessibleName;
PictureBox pictureBoxV = (PictureBox)sender;
DoDragDrop(pictureBoxV.Image, DragDropEffects.Copy);
}
private void pictureBox12_MouseMove(object sender, MouseEventArgs e)
{
if (e.Button == System.Windows.Forms.MouseButtons.Left)
{
pictureBox1.DoDragDrop(random1.ToString(), DragDropEffects.Copy);
}
}
private void pictureBox3_DragEnter(object sender, DragEventArgs e)
{
e.Effect = DragDropEffects.Move;
}
private void pictureBox3_DragDrop(object sender, DragEventArgs e)
{
int x = this.PointToClient(new Point(e.X, e.Y)).X;
int y = this.PointToClient(new Point(e.X, e.Y)).Y;
if (x >= pictureBox12.Location.X && x <= pictureBox12.Location.X + pictureBox12.Width && y >= pictureBox12.Location.Y && y <= pictureBox12.Location.Y + pictureBox12.Height)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
pictureBox1.Image = Image.FromFile(files[0]);
}
}
private void pictureBox3_DragOver(object sender, DragEventArgs e)
{
}