Version

ValueObjectChanging Event

Fired when the control's Value or ValueObject property is about to be changed.
Syntax
'Declaration
 
Public Event ValueObjectChanging As Infragistics.Win.UltraWinEditors.TrackBarValueChangingEventHandler
public event Infragistics.Win.UltraWinEditors.TrackBarValueChangingEventHandler ValueObjectChanging
Event Data

The event handler receives an argument of type Infragistics.Win.UltraWinEditors.TrackBarValueChangingEventArgs containing data related to this event. The following TrackBarValueChangingEventArgs properties provide information specific to this event.

PropertyDescription
NewValue  
OldValue  
Source  
Example
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
using Infragistics.Win.UltraWinEditors;

        private void ultraTrackBar1_ValueObjectChanging(object sender, Infragistics.Win.TrackBarValueChangingEventArgs e)
        {
            UltraTrackBar trackBar = sender as UltraTrackBar;

            // This sample code will prevent the thumb from snapping to a value unless that value is a 
            // multiple of a number.

            const int multiple = 5;
            
            // Is the value changing due to the dragging of the thumb?
            if (e.Source == TrackBarActionSource.Thumb)
            {                
                // Cast the NewValue to an int. 
                // Under some circumstances, NewValue could be null. 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.
                int newValue = (int)e.NewValue;

                int extra = newValue % multiple;
                    
                // Is the value not evenly divisible by 5. 
                if (extra != 0)
                {                    
                    newValue += (multiple - extra);

                    // Make sure the value doesn't go past the MaxValue. 
                    e.NewValue = Math.Min(newValue, trackBar.MaxValue);
                }
            }
        }
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also