How to disable MouseWheel for RadDateTimePicker

7 posts, 1 answers
  1. Taylor
    Taylor avatar
    17 posts
    Member since:
    Oct 2009

    Posted 25 Jan 2011 Link to this post

    My application has a RadDateTimePicker at the top of most forms; often the forms require some scrolling.  When a user enters the form, the RadDateTimePicker gets focus, and then when he tries to scroll down the form, he instead will inadvertently scroll the date, then (when the month reaches 12, its highest value) the form will scroll.  The user often will not know that he accidently changed a value.

    My users never want to scroll the date (they are always surprised when I point out to them that it does scroll), so I want to turn off that functionality.  My first thought was to get the event handler and set Handled to true ... but there is no such property on that event handler.  Then, even though I knew better, I tried to go down the road of removing the existing handlers ... but even Reflection balks at that.

    So, is there a way for me to disable the MouseWheel event in the RadDateTimePicker?  Or do you have alternate suggestions?

    Thanks!
  2. Answer
    Richard Slade
    Richard Slade avatar
    3000 posts
    Member since:
    May 2009

    Posted 25 Jan 2011 Link to this post

    Hi Brandon,

    This doesn't disable the mouse wheel, but it does reset the value, which in effect, renders the mouse wheel useless. There may be other ways, but it's the simplest solution I can think of so far.

        AddHandler Me.RadDateTimePicker1.DateTimePickerElement.TextBoxElement.TextBoxItem.MouseWheel, AddressOf RadDateTimePicker_MouseWheel
    Private Sub RadDateTimePicker_MouseWheel(ByVal sender As Object, ByVal e As MouseEventArgs)
        If e.Delta > 0 Then
            SendKeys.Send("{DOWN}")
        Else
            SendKeys.Send("{UP}")
        End If
    End Sub

    Hope that helps but let me know if you have any questions
    Regards,
    Richard
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Taylor
    Taylor avatar
    17 posts
    Member since:
    Oct 2009

    Posted 25 Jan 2011 Link to this post

    That did it.  Thanks!
  5. Joem
    Joem avatar
    11 posts
    Member since:
    Oct 2012

    Posted 04 Dec 2015 Link to this post

    Is this the best solution for the problem how to the scrolling of datetimepicker? MulticolumnCombobox has ScrollOnMouseWheel, why not a similar function for datetimepicker?
  6. Joem
    Joem avatar
    11 posts
    Member since:
    Oct 2012

    Posted 04 Dec 2015 in reply to Joem Link to this post

    Just to add,

    using the above workaround, upon scrolling on a datetimepicker set to nulltext, the control will be having a new value.

  7. Joem
    Joem avatar
    11 posts
    Member since:
    Oct 2012

    Posted 04 Dec 2015 in reply to Joem Link to this post

    I think this is the right choice.

    dateTimePicker.DateTimePickerElement.TextBoxElement.EnableMouseWheel = false;

  8. Hristo Merdjanov
    Admin
    Hristo Merdjanov avatar
    710 posts

    Posted 04 Dec 2015 Link to this post

    Hi Joem,

    Thank you for writing.

    The EnableMouseWheel property was introduced at the end of 2011, so with any later versions of the controls this is the correct way to handle this type of scenario.

    Should you have further questions please do not hesitate to write back.

    Regards,
    Hristo Merdjanov
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
UI for WinForms is Visual Studio 2017 Ready