ToolStripItem.MouseMove ToolStripItem.MouseMove ToolStripItem.MouseMove ToolStripItem.MouseMove Event

Definición

Se produce cuando el puntero del mouse se mueve sobre el elemento.Occurs when the mouse pointer is moved over the item.

public:
 event System::Windows::Forms::MouseEventHandler ^ MouseMove;
public event System.Windows.Forms.MouseEventHandler MouseMove;
member this.MouseMove : System.Windows.Forms.MouseEventHandler 
Public Custom Event MouseMove As MouseEventHandler 

Ejemplos

En el ejemplo de código siguiente se muestra el uso de este miembro.The following code example demonstrates the use of this member. En el ejemplo, un controlador de eventos informa sobre la aparición de la MouseMove eventos.In the example, an event handler reports on the occurrence of the MouseMove event. Este informe le ayuda a saber cuándo el evento se produce y puede ayudarle a depurar.This report helps you to learn when the event occurs and can assist you in debugging. Para informar sobre varios eventos o en eventos que se producen con frecuencia, considere reemplazar MessageBox.Show con Console.WriteLine o agregar el mensaje a un multilínea TextBox.To report on multiple events or on events that occur frequently, consider replacing MessageBox.Show with Console.WriteLine or appending the message to a multiline TextBox.

Para ejecutar el ejemplo de código, péguelo en un proyecto que contiene una instancia de un tipo que hereda de ToolStripItem, como un ToolStripButton o ToolStripMenuItem.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. A continuación, asigne a la instancia ToolStripItem1 y asegúrese de que está asociado el controlador de eventos con el MouseMove eventos.Then name the instance ToolStripItem1 and ensure that the event handler is associated with the MouseMove event.

private void ToolStripItem1_MouseMove(Object sender, MouseEventArgs e) {

System.Text.StringBuilder messageBoxCS = new System.Text.StringBuilder();
messageBoxCS.AppendFormat("{0} = {1}", "Button", e.Button );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Clicks", e.Clicks );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "X", e.X );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Y", e.Y );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Delta", e.Delta );
messageBoxCS.AppendLine();
messageBoxCS.AppendFormat("{0} = {1}", "Location", e.Location );
messageBoxCS.AppendLine();
MessageBox.Show(messageBoxCS.ToString(), "MouseMove Event" );
}
Private Sub ToolStripItem1_MouseMove(sender as Object, e as MouseEventArgs) _ 
     Handles ToolStripItem1.MouseMove

    Dim messageBoxVB as New System.Text.StringBuilder()
    messageBoxVB.AppendFormat("{0} = {1}", "Button", e.Button)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Clicks", e.Clicks)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "X", e.X)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Y", e.Y)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Delta", e.Delta)
    messageBoxVB.AppendLine()
    messageBoxVB.AppendFormat("{0} = {1}", "Location", e.Location)
    messageBoxVB.AppendLine()
    MessageBox.Show(messageBoxVB.ToString(),"MouseMove Event")

End Sub

Comentarios

Los eventos del mouse se producen en el siguiente orden:Mouse events occur in the following order:

  1. MouseEnter

  2. MouseMove

  3. MouseHover o MouseDownMouseHover or MouseDown

  4. MouseUp

  5. MouseLeave

Para obtener más información sobre el manejo de eventos, consulte controlar y provocar eventos.For more information about handling events, see Handling and Raising Events.

Se aplica a

Consulte también: