MouseWheelEventArgs.Delta Propriedade
Definição
Importante
Algumas informações dizem respeito a um produto pré-lançado que pode ser substancialmente modificado antes de ser lançado. A Microsoft não faz garantias, de forma expressa ou implícita, em relação à informação aqui apresentada.
Recebe um valor que indica a quantidade que a roda do rato mudou.
public:
property int Delta { int get(); };
public int Delta { get; }
member this.Delta : int
Public ReadOnly Property Delta As Integer
Valor de Propriedade
A quantidade que a roda mudou. Este valor é positivo se a roda do rato for rodada para cima (afastando-se do utilizador) ou negativo se a roda for rodada para baixo (em direção ao utilizador).
Exemplos
O exemplo seguinte move um TextBox para cima se a roda Delta do rato for positiva e move para baixo TextBox se a roda Delta do rato for negativa. O TextBox está ligado a um 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
Observações
Os intervalos superiores e inferiores efetivos deste valor podem vir de implementações de dispositivos ou outros chamadores que levantaram o evento, e por isso não estão definidos.