MouseWheelEventArgs.Delta Egenskap
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Hämtar ett värde som anger hur mycket mushjulet har ändrats.
public:
property int Delta { int get(); };
public int Delta { get; }
member this.Delta : int
Public ReadOnly Property Delta As Integer
Egenskapsvärde
Mängden hjulet har ändrats. Det här värdet är positivt om mushjulet roteras uppåt (bort från användaren) eller negativt om mushjulet roteras nedåt (mot användaren).
Exempel
I följande exempel flyttas en TextBox uppåt om mushjulet Delta är positivt och flyttar TextBox nedåt om mushjulet Delta är negativt. TextBox Är kopplad till en 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
Kommentarer
De effektiva övre och nedre intervallen för det här värdet kan komma från enhetsimplementeringar eller andra anropare som skapade händelsen och därför inte definieras.