Is there a way to literally drag the source picturebox across the screen in a drag and drop operation in c#?

Viewed 18

I'm working on a puzzle game, where I have a drag and drop operation going on to allow the user to move a puzzle piece(picturebox with an image on it) onto the board(picturebox without an image on it). The way I want the drag and drop operation to run is to physically have the puzzle piece drag across the screen and then drop its image onto the board. Any ideas? Also, here's some code for some more insight:

'''

    private void PB8Test_DragEnter(object sender, DragEventArgs e)
    {
        //this event will fire when you drag the mouse over this picturebox
        e.Effect = e.AllowedEffect;

    }

    private void PB8Test_DragDrop(object sender, DragEventArgs e)
    {
        PB8Test.AllowDrop = true;
        //this event will fire when you leave the mouse button, after you drag over it
        PB8Test.SizeMode = PictureBoxSizeMode.StretchImage;
        PB8Test.ImageLocation = PB8.ImageLocation;
        PB8.Visible = false;

    }

    private void PB8_MouseDown(object sender, MouseEventArgs e)
    {
        //this event will occur, when you perform drag operation
        PB8.DoDragDrop(PB8, DragDropEffects.Copy);
    }

    private void PB8_MouseEnter(object sender, EventArgs e)
    {
        //highlight the picturebox when the mouse hovers over it
        PB8.BorderStyle = BorderStyle.Fixed3D;
    }

    private void PB8_MouseMove(object sender, MouseEventArgs e)
    {
        //PICTUREBOX DOESN'T DRAG ACROSS THE SCREEN HERE. 

        PB8.Left += e.Location.X - _startLocation.X;
        PB8.Top += e.Location.Y - _startLocation.Y;
    }

'''

0 Answers
Related