ToolStripItem.DragDrop Evento
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
Se produce cuando el usuario arrastra un elemento y el usuario suelta el botón del mouse, lo que indica que el elemento debe colocarse en este elemento.
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
- Atributos
En el ejemplo de código siguiente se muestra cómo convertir las X propiedades y Y en un cliente Point. Este ejemplo de código es parte de un ejemplo mayor proporcionado para la clase ToolStripRenderer.
// 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
Las X propiedades y Y de están en coordenadas de DragEventArgs pantalla, no en coordenadas de cliente. Para obtener más información sobre el manejo de eventos, consulte controlar y provocar eventos.
Producto | Versiones |
---|---|
.NET Framework | 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 |
Comentarios de .NET
.NET es un proyecto de código abierto. Seleccione un vínculo para proporcionar comentarios: