I would like to allow my users to drag a couple of interface items around. At the moment, only seem able to draw directly to a graphics object using the Cursor.Draw method. I'd like to be able to show items being dragged around the screen, in the fashion of dragging Windows icons such as folders, which can be dragged from window to window and over the taskbar, and such. Does the dotnet framework provide the ability to do this, or would it require lots of hooking into scary Windows API functions?
我想允许我的用户拖动几个界面项目。目前,似乎只能使用Cursor.Draw方法直接绘制到图形对象。我希望能够以拖动Windows图标(如文件夹)的方式显示在屏幕上拖动的项目,这些图标可以从窗口拖到窗口和任务栏上等等。 dotnet框架是否提供了执行此操作的能力,还是需要大量连接到可怕的Windows API函数?
EDIT: I want, while I am dragging stuff, to be able to see an image of the thing that I am dragging displayed next to the mouse cursor. I want to be able to drag the item outside of the window, and to continue to display it next to the mouse cursor.
编辑:我想,当我拖动东西时,能够看到我拖动的东西显示在鼠标光标旁边的图像。我希望能够将项目拖到窗口外,并继续在鼠标光标旁边显示它。
2 个解决方案
#1
I wonder if this may be of use: Drag and Drop in Windows Forms - A Primer
我想知道这是否有用:在Windows窗体中拖放 - 一个入门
#2
We have a simialr question in SO. Move a picture box with Mouse . You can use the same thing (?) . keep your icons in the picture box and let the users move it.
我们在SO中有一个类似的问题。使用鼠标移动图片框。你可以使用相同的东西(?)。将图标保留在图片框中,让用户移动它。
#1
I wonder if this may be of use: Drag and Drop in Windows Forms - A Primer
我想知道这是否有用:在Windows窗体中拖放 - 一个入门
#2
We have a simialr question in SO. Move a picture box with Mouse . You can use the same thing (?) . keep your icons in the picture box and let the users move it.
我们在SO中有一个类似的问题。使用鼠标移动图片框。你可以使用相同的东西(?)。将图标保留在图片框中,让用户移动它。