com*_*cme 5 c# controls drag-and-drop winforms
我想知道我在Windows窗体应用程序中调用DoDragDrop方法的控件是否有任何区别.
我有一个带有两个PictureBox控件的Form.可以拖动一个,另一个将其AllowDrop属性设置为true.
可拖动PictureBox的MouseDown事件处理程序如下:
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);
}
}
Run Code Online (Sandbox Code Playgroud)
但是我没有在pictureBox上调用DoDragDrop,我似乎可以使用任何控件,例如Form本身
var effect = this.DoDragDrop(pictureBox.Image, DragDropEffects.All);
Run Code Online (Sandbox Code Playgroud)
甚至
var effect = label1.DoDragDrop(pictureBox.Image, DragDropEffects.All);
Run Code Online (Sandbox Code Playgroud)
对我称之为DoDragDrop方法的控件有什么不同?如果是这样,有什么区别?
| 归档时间: |
|
| 查看次数: |
1986 次 |
| 最近记录: |