MouseWheelEventArgs.Delta Eigenschaft

Definition

Ruft einen Wert ab, der angibt, wie viel das Mausrad geändert hat.

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

Eigenschaftswert

Der Betrag, den das Rad geändert hat. Dieser Wert ist positiv, wenn das Mausrad in eine Richtung nach oben gedreht wird (weg vom Benutzer) oder negativ, wenn das Mausrad in eine Richtung nach unten gedreht wird (gegenüber dem Benutzer).

Beispiele

Das folgende Beispiel bewegt sich nach TextBox oben, wenn das Mausrad Delta positiv ist und nach TextBox unten bewegt wird, wenn das Mausrad Delta negativ ist. Dies TextBox ist an eine Canvas.

// 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

Hinweise

Die effektiven oberen und unteren Bereiche dieses Werts stammen möglicherweise aus Geräteimplementierungen oder anderen Aufrufern, die das Ereignis ausgelöst haben, und sind daher nicht definiert.

Gilt für:

Weitere Informationen