如何在拖动时获取 MouseCursor 下的 ListViewItem。超过它
我正在实施拖放放在 ListView 上。当将 ListViewItem 放在鼠标上时,我已经设法在光标下获取 ListViewItem,但我想在拖动某物时在鼠标光标下获取 ListViewItem。在 ListView 控件上。
当您将文件拖到文件夹上时,我想像在 Windows 资源管理器中一样选择 ListViewItem (selected=true)。
我考虑过 ListView 中的 ItemMouseHover、MouseMove 等事件,但拖动时不会触发它们。超过它。
希望你能帮助我...
问候,
inno
P.S.:我正在使用.Net2.0
I'm implementing drag & drop on a ListView. I already managed to get the ListViewItem under the cursor when dropping on it but I would like to get the ListViewItem under the mouse cursor while I'm dragging sth. over the ListView-Control.
I would like to select the ListViewItem (selected=true) like in Windows Explorer when you are dragging files over a folder.
I thought about events like ItemMouseHover, MouseMove in the ListView but they are not fired when dragging sth. over it.
Hope you can help me...
Regards,
inno
P.S.: I'm using .Net2.0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过响应 listview 类中的 DragOver 事件?你应该能够这样做。
Have you tried responding to the DragOver event in the listview class? You should be able to do it this way.
如果您在 ListView 中进行拖放操作,则通过查看 ObjectListView(.NET WinForms ListView 的开源包装器)。
如果您使用 ObjectListView 而不是普通的 ListView,许多事情(例如拖放)会自动发生。
If you are doing drag and drop in a ListView, you learn a lot by looking at the code of ObjectListView (an open source wrapper around .NET WinForms ListView).
If you use an ObjectListView instead of a normal ListView, a lot of things, like drag and drop, happen automatically.