QueryContinueDragEventArgs 类

定义

QueryContinueDrag 事件提供数据。Provides data for the QueryContinueDrag event.

public ref class QueryContinueDragEventArgs : EventArgs
[System.Runtime.InteropServices.ComVisible(true)]
public class QueryContinueDragEventArgs : EventArgs
type QueryContinueDragEventArgs = class
    inherit EventArgs
Public Class QueryContinueDragEventArgs
Inherits EventArgs
继承
QueryContinueDragEventArgs
属性

示例

此代码摘录演示了如何QueryContinueDragEventArgs将类QueryContinueDrag与事件一起使用。This code excerpt demonstrates using the QueryContinueDragEventArgs class with the QueryContinueDrag event. 有关完整的代码示例, 请参阅方法。DoDragDropSee the DoDragDrop method for the complete code example.

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;
      }
   }
}
private void ListDragSource_QueryContinueDrag(object sender, System.Windows.Forms.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, System.Windows.Forms.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事件在拖放操作期间发生, 并且允许拖动源确定是否应取消拖放操作。The QueryContinueDrag event occurs during a drag-and-drop operation and allows the drag source to determine whether the drag-and-drop operation should be canceled. QueryContinueDragEventArgs指定是否以及如何进行拖放操作、是否按下任何修改键, 以及用户是否已按 ESC 键。A QueryContinueDragEventArgs specifies whether and how the drag-and-drop operation should proceed, whether any modifier keys are pressed, and whether the user has pressed the ESC key.

默认情况下,如果按 Esc 键,则 QueryContinueDrag 事件将 Action 设置为 DragAction.Cancel;如果按鼠标左键、中键或右键,则将 Action 设置为 DragAction.DropBy default, the QueryContinueDrag event sets Action to DragAction.Cancel if the ESC key was pressed and sets Action to DragAction.Drop if the left, middle, or right mouse button is pressed.

有关事件模型的信息, 请参阅处理和引发事件For information about the event model, see Handling and Raising Events.

构造函数

QueryContinueDragEventArgs(Int32, Boolean, DragAction)

初始化 QueryContinueDragEventArgs 类的新实例。Initializes a new instance of the QueryContinueDragEventArgs class.

属性

Action

获取或设置拖放操作的状态。Gets or sets the status of a drag-and-drop operation.

EscapePressed

获取该用户是否按下 Esc 键。Gets whether the user pressed the ESC key.

KeyState

获取 Shift、Ctrl 和 Alt 键的当前状态。Gets the current state of the SHIFT, CTRL, and ALT keys.

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅