I'm curious, it doesn't matter which control I call the DoDragDrop method in a Windows Forms application.
I have a form with two PictureBox controls. It can be dragged and the other has the AllowsDrop property set to true.
The MouseDown event handler for a dragged PictureBox looks like this:
private void dragPictureBox_MouseDown(object sender, MouseEventArgs e)
{
if (sender is PictureBox)
{
var pictureBox = (PictureBox) sender;
var effect = pictureBox.DoDragDrop(
pictureBox.Image, DragDropEffects.All);
MessageBox.Show("Drag ended in a " + effect);
}
}
But instead of calling DoDragDrop on the pictureBox, it seems to me that I can use any control, for example, Form itself
var effect = this.DoDragDrop(pictureBox.Image, DragDropEffects.All);
or even
var effect = label1.DoDragDrop(pictureBox.Image, DragDropEffects.All);
Is there any difference in which control I call the DoDragDrop method? And if so, what's the difference?
source
share