QueryContinueDragEventArgs 类
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
为 QueryContinueDrag 事件提供数据。
public ref class QueryContinueDragEventArgs : EventArgs
C#
[System.Runtime.InteropServices.ComVisible(true)]
public class QueryContinueDragEventArgs : EventArgs
C#
public class QueryContinueDragEventArgs : EventArgs
[<System.Runtime.InteropServices.ComVisible(true)>]
type QueryContinueDragEventArgs = class
inherit EventArgs
type QueryContinueDragEventArgs = class
inherit EventArgs
Public Class QueryContinueDragEventArgs
Inherits EventArgs
- 继承
- 属性
此代码摘录演示如何将 QueryContinueDragEventArgs 类与 事件一起使用 QueryContinueDrag 。 有关完整的代码示例, DoDragDrop 请参阅 方法。
void ListDragSource_QueryContinueDrag( Object^ sender, System::Windows::Forms::QueryContinueDragEventArgs^ e )
{
// Cancel the drag if the mouse moves off the form.
ListBox^ lb = dynamic_cast<ListBox^>(sender);
if ( lb != nullptr )
{
Form^ f = lb->FindForm();
// Cancel the drag if the mouse moves off the form. The screenOffset
// takes into account any desktop bands that may be at the top or left
// side of the screen.
if ( ((Control::MousePosition.X - screenOffset.X) < f->DesktopBounds.Left) || ((Control::MousePosition.X - screenOffset.X) > f->DesktopBounds.Right) || ((Control::MousePosition.Y - screenOffset.Y) < f->DesktopBounds.Top) || ((Control::MousePosition.Y - screenOffset.Y) > f->DesktopBounds.Bottom) )
{
e->Action = DragAction::Cancel;
}
}
}
C#
private void ListDragSource_QueryContinueDrag(object sender, QueryContinueDragEventArgs e)
{
// Cancel the drag if the mouse moves off the form.
ListBox lb = sender as ListBox;
if (lb != null)
{
Form f = lb.FindForm();
// Cancel the drag if the mouse moves off the form. The screenOffset
// takes into account any desktop bands that may be at the top or left
// side of the screen.
if (((Control.MousePosition.X - screenOffset.X) < f.DesktopBounds.Left) ||
((Control.MousePosition.X - screenOffset.X) > f.DesktopBounds.Right) ||
((Control.MousePosition.Y - screenOffset.Y) < f.DesktopBounds.Top) ||
((Control.MousePosition.Y - screenOffset.Y) > f.DesktopBounds.Bottom))
{
e.Action = DragAction.Cancel;
}
}
}
Private Sub ListDragSource_QueryContinueDrag(ByVal sender As Object, ByVal e As QueryContinueDragEventArgs) Handles ListDragSource.QueryContinueDrag
' Cancel the drag if the mouse moves off the form.
Dim lb As ListBox = CType(sender, ListBox)
If (lb IsNot Nothing) Then
Dim f As Form = lb.FindForm()
' Cancel the drag if the mouse moves off the form. The screenOffset
' takes into account any desktop bands that may be at the top or left
' side of the screen.
If (((Control.MousePosition.X - screenOffset.X) < f.DesktopBounds.Left) Or
((Control.MousePosition.X - screenOffset.X) > f.DesktopBounds.Right) Or
((Control.MousePosition.Y - screenOffset.Y) < f.DesktopBounds.Top) Or
((Control.MousePosition.Y - screenOffset.Y) > f.DesktopBounds.Bottom)) Then
e.Action = DragAction.Cancel
End If
End If
End Sub
该 QueryContinueDrag 事件在拖放操作期间发生,并允许拖动源确定是否应取消拖放操作。 指定 QueryContinueDragEventArgs 是否以及如何继续拖放操作,是否按下任何修改键,以及用户是否按下了 ESC 键。
默认情况下,如果按 Esc 键,则 QueryContinueDrag 事件将 Action 设置为 DragAction.Cancel;如果按鼠标左键、中键或右键,则将 Action
设置为 DragAction.Drop。
有关事件模型的信息,请参阅 处理和引发事件。
Action |
获取或设置拖放操作的状态。 |
Escape |
获取该用户是否按下 Esc 键。 |
Key |
获取 Shift、Ctrl 和 Alt 键的当前状态。 |
Equals(Object) |
确定指定对象是否等于当前对象。 (继承自 Object) |
Get |
作为默认哈希函数。 (继承自 Object) |
Get |
获取当前实例的 Type。 (继承自 Object) |
Memberwise |
创建当前 Object 的浅表副本。 (继承自 Object) |
To |
返回表示当前对象的字符串。 (继承自 Object) |
产品 | 版本 |
---|---|
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9, 10 |