Este artigo foi traduzido por máquina. Coloque o ponteiro do mouse sobre as frases do artigo para ver o texto original. Mais informações.
Tradução
Original
Este tópico ainda não foi avaliado como - Avalie este tópico

ToolStripItem.QueryContinueDrag Evento

Ocorre durante uma drag-and-Soltar operation e permite que o arrastar Origem para determinar se o drag-and-Soltar operation deve ser cancelada.

Namespace:  System.Windows.Forms
Assembly:  System.Windows.Forms (em System.Windows.Forms. dll)
[BrowsableAttribute(false)]
public event QueryContinueDragEventHandler QueryContinueDrag

The QueryContinueDrag event is raised when there is a change in the keyboard or mouse button state during a drag-and-drop operation.The QueryContinueDrag event allows the drag source to determine whether the drag-and-drop operation should be canceled.

Os comentários a seguir descrevem como e quando eventos relacionados a operações de arrastar-e-soltar são aumentados.

The DoDragDrop method determines the item under the current cursor location.Em seguida, ele verifica se o item é um destino de soltar válido.

If the item is a valid drop target, the GiveFeedback event is raised with the drag-and-drop effect specified.For a list of drag-and-drop effects, see the DragDropEffects enumeration.

As alterações na posição do cursor do mouse, teclado estado e estado do botão do mouse são controladas da seguinte maneira:

  • If the user moves out of a window, the DragLeave event is raised.

  • If the mouse enters another item, the DragEnter for that control is raised.

  • If the mouse moves but stays within the same item, the DragOver event is raised.

If there is a change in the keyboard or mouse button state, the QueryContinueDrag event is raised and determines whether to continue the drag, to drop the data, or to cancel the operation based on the value of the Action property of the event's QueryContinueDragEventArgs.

If the value of DragAction is Continue, the DragOver event is raised to continue the operation and the GiveFeedback event is raised with the new effect so appropriate visual feedback can be set.For a list of valid drop effects, see the DragDropEffects enumeration.

The DragOver and GiveFeedback events are paired so that as the mouse moves across the drop target, the user is given the most up-to-date feedback on the mouse's position, as follows:

  • If the value of DragAction is Drop, the drop effect value is returned to the source, so the source application can perform the appropriate operation on the source data; for example, cut the data if the operation was a move.

  • If the value of DragAction is Cancel, the DragLeave event is raised.

O exemplo de código a seguir demonstra o uso desse membro.In the example, an event handler reports on the occurrence of the QueryContinueDrag event.Esse relatório ajuda você a saber quando o evento ocorre e pode ajudá-lo a depurar.Para relatar múltiplos eventos ou eventos que ocorrem com freqüência, considere substituir MessageBox.Show por Console.WriteLine ou anexar a mensagem em um TextBox com multi-linhas.

To run the example code, paste it into a project that contains an instance of a type that inherits from ToolStripItem, such as a ToolStripButton or ToolStripMenuItem.Then name the instance ToolStripItem1 and ensure that the event handler is associated with the QueryContinueDrag event.

private void ToolStripItem1_QueryContinueDrag(Object sender, QueryContinueDragEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "KeyState", e.KeyState );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "EscapePressed", e.EscapePressed );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Action", e.Action );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "QueryContinueDrag Event" );
}


Isso foi útil para você?
(1500 caracteres restantes)

Contribuições da comunidade

ADICIONAR
© 2013 Microsoft. Todos os direitos reservados.