Lock mouse scroll in a combo box...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Aimee Bailey
    Recognized Expert New Member
    • Apr 2010
    • 197

    #1

    Lock mouse scroll in a combo box...

    Hi, i've been trying to stop the user from scrolling their mouse inside a WPF combobox, does anyone know how this can be achieved?

    .Net 4.0
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #2
    Hi Aimee,

    I don't know very much WPF, but I was able to do this in WinForms so hopefully it helps. I got this working by creating a new class and inheriting from a ComboBox. Then I created an override on the WndProc method and checked for the mouse wheel message. If I got that one, I did nothing, otherwise I just called the base WndProc.

    This prevented the mouse wheel from scrolling my combo box, but everything else was fine.

    The code for WM_MOUSEWHEEL is 0x020A. Hopefully you're able to convert that to a WPF equivalent.

    Comment

    • Curtis Rutland
      Recognized Expert Specialist
      • Apr 2008
      • 3264

      #3
      Perhaps this thread will help:
      http://stackoverflow.com/questions/2...control-in-wpf

      Comment

      • GaryTexmo
        Recognized Expert Top Contributor
        • Jul 2009
        • 1501

        #4
        So, it looks like this is easier said than done with WPF. I did some googling around and you can indeed override WndProc on WPF, kinda... but it's a pain.

        I don't really understand this (ie, I can't get it to work) but I'm not well versed in WPF. Perhaps this will help?

        Comment

        • Aimee Bailey
          Recognized Expert New Member
          • Apr 2010
          • 197

          #5
          Thanks for your replies, in the end i stopped the entire grid from scroll mousing, it takes away a little functionallity, but then again on the bright side a hundred queries to the database are not being sent anymore either :)

          Aimee.

          Comment

          Working...