English 中文(简体)
难道这是你称之为DragDrop方法的控制问题吗?
原标题:Does it matter on which control you call the DoDragDrop method?

我很想知道,它是否对我称之为“DoDragDrop”方法的视窗应用产生任何影响。

我有一个表格,有两种图像Box控制。 一个人可以被拖走,而另一个人则拥有真正的许可财产。

The MouseDown event handler for the draggable PictureBox is as follows:

    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);
        }
    }

但是,为了不把DoDragDrop放在图像Box上,我似乎也能够使用任何控制,例如表格本身。

var effect = this.DoDragDrop(pictureBox.Image, DragDropEffects.All);

甚至

var effect = label1.DoDragDrop(pictureBox.Image, DragDropEffects.All);

这是否改变了我称之为DragDrop方法的控制? 如果是的话,那会有什么区别?

最佳回答

It s not very well documented, but I believe it effects which control would have the QueryContinueDrag event raised on it.

所有这些例子都倾向于使用拖拉数据的来源,因此我坚持使用这一数据。

问题回答

暂无回答




相关问题
Bring window to foreground after Mutex fails

I was wondering if someone can tell me what would be the best way to bring my application to the foreground if a mutex was not able to be created for a new instance. E.g.: Application X is running ...

How to start WinForm app minimized to tray?

I ve successfully created an app that minimizes to the tray using a NotifyIcon. When the form is manually closed it is successfully hidden from the desktop, taskbar, and alt-tab. The problem occurs ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

Handle DataTable.DataRow cell change event

I have a DataTable that has several DataColumns and DataRow. Now i would like to handle an event when cell of this DataRow is changed. How to do this in c#?

Apparent Memory Leak in DataGridView

How do you force a DataGridView to release its reference to a bound DataSet? We have a rather large dataset being displayed in a DataGridView and noticed that resources were not being freed after the ...

ALT Key Shortcuts Hidden

I am using VS2008 and creating forms. By default, the underscore of the character in a textbox when using an ampersand is not shown when I run the application. ex. "&Goto Here" is not ...

WPF-XAML window in Winforms Application

I have a Winforms application coded in VS C# 2008 and want to insert a WPF window into the window pane of Winforms application. Could you explain me how this is done.

热门标签