ToolStripItem.DragDrop Evento
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Ocorre quando o utilizador arrasta um item e solta o botão do rato, indicando que o item deve ser colocado nesse item.
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
Tipo de Evento
- Atributos
Exemplos
O seguinte exemplo de código mostra como converter as X propriedades e Y para um cliente Point. Este exemplo de código faz parte de um exemplo maior fornecido para a ToolStripRenderer classe.
// 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
Observações
As X propriedades e Y do DragEventArgs estão nas coordenadas do ecrã, não nas coordenadas do cliente. Para obter mais informações sobre como manipular eventos, consulte Manipulando e gerando eventos.