radDateTimePicker to next or Previous Months

1 Answer 77 Views
Calendar, DateTimePicker, TimePicker and Clock TimePicker
ebrahim
Top achievements
Rank 1
Iron
Iron
ebrahim asked on 13 Jan 2022, 08:22 AM
   

hi tanks for all controls

what by MouseWheel change mount in radtimepicker and calander

 

Sample code not work!
private void radDateTimePicker_RootElement_MouseWheel(object sender, MouseEventArgs e)
        {

            if(e.Delta>0)
            {

                radDateTimePicker.Value.AddMonths(1);

            }
        }

           

1 Answer, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 13 Jan 2022, 11:51 AM

Hello, Ebrahim,

If I understand your requirement correctly, you need to change the month value with +1/-1 using the mouse wheel. Please correct me if I am wrong. 

This behavior is supported out of the box but it requires first selecting the desired date part that you want to change, e.g. month, day, year. The attached gif file illustrates better what I mean.

However, if you want to change only the month, it is necessary to disable the default mouse wheel logic and execute the custom action that you want:

        public RadForm1()
        {
            InitializeComponent();

            this.radDateTimePicker1.DateTimePickerElement.TextBoxElement.TextBoxItem.TextBoxControl.MouseWheel += TextBoxItem_MouseWheel; 

            //disable the defautl logic for mouse wheel
            this.radDateTimePicker1.DateTimePickerElement.TextBoxElement.EnableMouseWheel = false; 
        } 

        private void TextBoxItem_MouseWheel(object sender, MouseEventArgs e)
        {
            if (e.Delta > 0)
            {
                Console.WriteLine(this.radDateTimePicker1.Value);
                this.radDateTimePicker1.Value = this.radDateTimePicker1.Value.AddMonths(1);
            } 
        }

I hope this information helps. If you need any further assistance please don't hesitate to contact me. 

Regards,
Dess | Tech Support Engineer, Principal
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Calendar, DateTimePicker, TimePicker and Clock TimePicker
Asked by
ebrahim
Top achievements
Rank 1
Iron
Iron
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or