QueryContinueDragEventArgs QueryContinueDragEventArgs QueryContinueDragEventArgs QueryContinueDragEventArgs Class

Definizione

Fornisce dati per l'evento 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
Ereditarietà
QueryContinueDragEventArgsQueryContinueDragEventArgsQueryContinueDragEventArgsQueryContinueDragEventArgs
Attributi

Esempi

Questo estratto di codice viene illustrato come utilizzare il QueryContinueDragEventArgs classe con il QueryContinueDrag evento.This code excerpt demonstrates using the QueryContinueDragEventArgs class with the QueryContinueDrag event. Vedere il DoDragDrop metodo per l'esempio di codice completo.See 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

Commenti

Il QueryContinueDrag evento si verifica durante un'operazione di trascinamento e rilascio e consente all'origine del trascinamento di determinare se l'operazione di trascinamento e rilascio deve essere annullata.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. Oggetto QueryContinueDragEventArgs specifica se e come l'operazione di trascinamento e rilascio deve continuare se vengono premuti i tasti di modifica e se l'utente ha premuto il tasto 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.

Per impostazione predefinita, l'evento QueryContinueDrag imposta la proprietà Action su DragAction.Cancel se è stato premuto ESC e imposta la proprietà Action su DragAction.Drop se è premuto il pulsante sinistro, centrale o destro del mouse.By 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.

Per informazioni sul modello di eventi, vedere la gestione e generazione di eventi.For information about the event model, see Handling and Raising Events.

Costruttori

QueryContinueDragEventArgs(Int32, Boolean, DragAction) QueryContinueDragEventArgs(Int32, Boolean, DragAction) QueryContinueDragEventArgs(Int32, Boolean, DragAction) QueryContinueDragEventArgs(Int32, Boolean, DragAction)

Inizializza una nuova istanza della classe QueryContinueDragEventArgs.Initializes a new instance of the QueryContinueDragEventArgs class.

Proprietà

Action Action Action Action

Ottiene o imposta lo stato dell'operazione di trascinamento e rilascio.Gets or sets the status of a drag-and-drop operation.

EscapePressed EscapePressed EscapePressed EscapePressed

Stabilisce se l'utente ha premuto il tasto ESC.Gets whether the user pressed the ESC key.

KeyState KeyState KeyState KeyState

Ottiene lo stato corrente dei tasti MAIUSC, CTRL e ALT.Gets the current state of the SHIFT, CTRL, and ALT keys.

Metodi

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determina se l'oggetto specificato è uguale all'oggetto corrente.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Funge da funzione hash predefinita.Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Ottiene l'oggetto Type dell'istanza corrente.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Crea una copia superficiale dell'oggetto Object corrente.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

Restituisce una stringa che rappresenta l'oggetto corrente.Returns a string that represents the current object.

(Inherited from Object)

Si applica a

Vedi anche