Imports Infragistics.Win.UltraWinEditors
Private Sub UltraTrackBar1_ValueObjectChanging(ByVal sender As System.Object, ByVal e As Infragistics.Win.TrackBarValueChangingEventArgs) Handles UltraTrackBar1.ValueObjectChanging
Dim trackBar As UltraTrackBar = CType(sender, UltraTrackBar)
' This sample code will prevent the thumb from snapping to a value unless that value is a
' multiple of a number.
Const multiple As Integer = 5
' Is the value changing due to the dragging of the thumb?
If (e.Source = TrackBarActionSource.Thumb) Then
' Cast the NewValue to an Integer.
' Under some circumstances, NewValue could be Nothing. Or it could be any object, since
' the control supports DataFilters.
' In this case, we will assume that nulls and DataFilters are not being used.
Dim newValue As Integer = CType(e.NewValue, Integer)
Dim extra As Integer = newValue Mod multiple
' Is the value not evenly divisible by 5.
If (extra <> 0) Then
newValue += (multiple - extra)
' Make sure the value doesn't go past the MaxValue.
e.NewValue = Math.Min(newValue, trackBar.MaxValue)
End If
End If
End Sub