MouseWheelEventArgs.Delta Właściwość

Definicja

Pobiera wartość wskazującą, że koło myszy uległo zmianie.

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

Wartość właściwości

Ilość, jaką zmienia koło. Ta wartość jest dodatnia, jeśli koło myszy jest obracane w kierunku w górę (z dala od użytkownika) lub ujemne, jeśli koło myszy jest obracane w kierunku w dół (w kierunku użytkownika).

Przykłady

Poniższy przykład przenosi wskaźnik w górę TextBox , jeśli koło Delta myszy jest dodatnie i przesuwa TextBox w dół, jeśli koło Delta myszy jest ujemne. Element TextBox jest dołączony do elementu 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

Uwagi

Skuteczne górne i niższe zakresy tej wartości mogą pochodzić z implementacji urządzeń lub innych wywołujących, które podniosły zdarzenie i dlatego nie są zdefiniowane.

Dotyczy

Zobacz też