ToolStripItem.DragDrop Ereignis

Definition

Tritt auf, wenn der Benutzer ein Element zieht und der Benutzer die Maustaste loslässt und angibt, dass das Element in dieses Element abgelegt werden soll.

public:
 event System::Windows::Forms::DragEventHandler ^ DragDrop;
[System.ComponentModel.Browsable(false)]
public event System.Windows.Forms.DragEventHandler DragDrop;
[System.ComponentModel.Browsable(false)]
public event System.Windows.Forms.DragEventHandler? DragDrop;
[<System.ComponentModel.Browsable(false)>]
member this.DragDrop : System.Windows.Forms.DragEventHandler 
Public Custom Event DragDrop As DragEventHandler 

Ereignistyp

Attribute

Beispiele

Das folgende Codebeispiel zeigt, wie die Eigenschaften und X die Y Eigenschaften in einen Client Pointkonvertiert werden. Dieses Codebeispiel ist Teil eines größeren Beispiels, das für die ToolStripRenderer Klasse bereitgestellt wird.

// This method defines the DragOver event behavior. 
protected override void OnDragOver(DragEventArgs dea)
{
    base.OnDragOver(dea);

    // Get the ToolStripButton control 
    // at the given mouse position.
    Point p = new Point(dea.X, dea.Y);
    ToolStripButton item = this.GetItemAt(
        this.PointToClient(p)) as ToolStripButton;

    // If the ToolStripButton control is the empty cell,
    // indicate that the move operation is valid.
    if( item == this.emptyCellButton )
    {
        // Set the drag operation to indicate a valid move.
        dea.Effect = DragDropEffects.Move;
    }
}
' This method defines the DragOver event behavior. 
Protected Overrides Sub OnDragOver(dea As DragEventArgs)
   MyBase.OnDragOver(dea)
   
   ' Get the ToolStripButton control 
   ' at the given mouse position.
   Dim p As New Point(dea.X, dea.Y)
   Dim item As ToolStripButton = CType(Me.GetItemAt(Me.PointToClient(p)), ToolStripButton)
   
   
   ' If the ToolStripButton control is the empty cell,
   ' indicate that the move operation is valid.
     If item Is Me.emptyCellButton Then
         ' Set the drag operation to indicate a valid move.
         dea.Effect = DragDropEffects.Move
     End If
 End Sub

Hinweise

Die X Eigenschaften und Eigenschaften der Y Daten befinden sich in Bildschirmkoordinaten, nicht in ClientkoordinatenDragEventArgs. Weitere Informationen zur Behandlung von Ereignissen finden Sie unter behandeln und Auslösen von Ereignissen.

Gilt für: