Articles in this section
Category / Section

How to increment and decrement the interval value of TimeSpanEdit?

1 min read

By default, the interval to increment or decrement the value of TimeSpanEdit will be 1(one). We can increment or decrement an interval value of TimeSpanEdit by handling PreviewMouseDown event. In this example, value(minutes) of TimeSpanEdit will be incremented or decremented using PreviewMouseDown event.

<syncfusion:TimeSpanEdit x:Name="timespanedit" Value="2:25:52" Format=" h 'hours' m 
                         'minutes' :s 'sec' z 'msec'" Width="250" Height="40" />

 

        public MainWindow()
        {
            InitializeComponent();
            timespanedit.Loaded += Timespanedit_Loaded;
              
        }
        RepeatButton upbutton = null;
        RepeatButton downbutton = null;
        private void Timespanedit_Loaded(object sender, RoutedEventArgs e)
        {
            if (upbutton == null && downbutton == null)
            {
              upbutton = timespanedit.Template.FindName("upbutton", timespanedit) 
                                                                   as  RepeatButton;
              downbutton = timespanedit.Template.FindName("downbutton", timespanedit)
                                                                    as RepeatButton;
                if (upbutton != null)
                    upbutton.PreviewMouseDown += new 
                           MouseButtonEventHandler(Timespanedit_PreviewMouseDown);
 
                if (downbutton != null)
                    downbutton.PreviewMouseDown += new 
                           MouseButtonEventHandler(Timespanedit_PreviewMouseDown1);
            }
        }
 
     private void Timespanedit_PreviewMouseDown1(object sender, MouseButtonEventArgs e)
     {
           
            timespanedit.Value -= new TimeSpan(0, 15, 0);
            e.Handled = true;
     }
 
      void Timespanedit_PreviewMouseDown(object sender, MouseButtonEventArgs e)
      {
         timespanedit.Value += new TimeSpan(0, 15, 0);
         e.Handled = true;
      }

 

Output:

C:\Users\durga.rajan\Pictures\Screenshots\Screenshot (253).png

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied