MouseWheelEventArgs.Delta Propiedad

Definición

Obtiene un valor que indica la medida en que ha cambiado la rueda del mouse.

public:
 property int Delta { int get(); };
public int Delta { get; }
member this.Delta : int
Public ReadOnly Property Delta As Integer

Valor de propiedad

Medida en que ha cambiado la rueda. Este valor es positivo si la rueda del mouse gira hacia arriba (alejándose del usuario) y es negativo si la rueda del mouse gira hacia abajo (hacia el usuario).

Ejemplos

En el ejemplo siguiente se mueve hacia TextBox arriba si la rueda Delta del mouse es positiva y se mueve hacia TextBox abajo si la rueda Delta del mouse es negativa. TextBox está asociado a un Canvasobjeto .

// Moves the TextBox named box when the mouse wheel is rotated.
// The TextBox is on a Canvas named MainCanvas.
private void MouseWheelHandler(object sender, MouseWheelEventArgs e)
{
    // If the mouse wheel delta is positive, move the box up.
    if (e.Delta > 0)
    {
        if (Canvas.GetTop(box) >= 1)
        {
            Canvas.SetTop(box, Canvas.GetTop(box) - 1);
        }
    }

    // If the mouse wheel delta is negative, move the box down.
    if (e.Delta < 0)
    {
        if ((Canvas.GetTop(box) + box.Height) <= (MainCanvas.Height))
        {
            Canvas.SetTop(box, Canvas.GetTop(box) + 1);
        }
    }
}
' Moves the TextBox named box when the mouse wheel is rotated.
' The TextBox is on a Canvas named MainCanvas.
Private Sub MouseWheelHandler(ByVal sender As Object, ByVal e As MouseWheelEventArgs)
    ' If the mouse wheel delta is positive, move the box up.
    If e.Delta > 0 Then
        If Canvas.GetTop(box) >= 1 Then
            Canvas.SetTop(box, Canvas.GetTop(box) - 1)
        End If
    End If

    ' If the mouse wheel delta is negative, move the box down.
    If e.Delta < 0 Then
        If (Canvas.GetTop(box) + box.Height) <= MainCanvas.Height Then
            Canvas.SetTop(box, Canvas.GetTop(box) + 1)
        End If
    End If

End Sub

Comentarios

Los intervalos superiores e inferiores efectivos de este valor pueden provenir de implementaciones de dispositivo u otros autores de llamadas que generaron el evento y, por tanto, no se definen.

Se aplica a

Consulte también