Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. ComboBox Scrollwheel disable

ComboBox Scrollwheel disable

Scheduled Pinned Locked Moved C#
question
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    R Myers
    wrote on last edited by
    #1

    Hello, Is there any way to disable the scrollwheel function for a ComboBox? Thanks R.Myers

    D 2 Replies Last reply
    0
    • R R Myers

      Hello, Is there any way to disable the scrollwheel function for a ComboBox? Thanks R.Myers

      D Offline
      D Offline
      DaveyM69
      wrote on last edited by
      #2

      The combobox has a MouseWheel event but it appears to have no way of altering the data (the properties are all read only) or cancelling. You may have to invesigate in the API: WM_MOUSEWHEEL[^]

      1 Reply Last reply
      0
      • R R Myers

        Hello, Is there any way to disable the scrollwheel function for a ComboBox? Thanks R.Myers

        D Offline
        D Offline
        DaveyM69
        wrote on last edited by
        #3

        This works!

        namespace WindowsFormsApplication1
        {
        public partial class Form1 : Form, IMessageFilter
        {
        private const int WM_MOUSEWHEEL = 0x20A;
        public bool PreFilterMessage(ref Message m)
        {
        if (m.Msg == WM_MOUSEWHEEL && this.ActiveControl == comboBox1)
        {
        return true;
        }

                return false;
            }
        
            public Form1()
            {
                InitializeComponent();
            }
        
            private void Form1\_Load(object sender, EventArgs e)
            {
                Application.AddMessageFilter(this);
            }
        }
        

        }

        R 1 Reply Last reply
        0
        • D DaveyM69

          This works!

          namespace WindowsFormsApplication1
          {
          public partial class Form1 : Form, IMessageFilter
          {
          private const int WM_MOUSEWHEEL = 0x20A;
          public bool PreFilterMessage(ref Message m)
          {
          if (m.Msg == WM_MOUSEWHEEL && this.ActiveControl == comboBox1)
          {
          return true;
          }

                  return false;
              }
          
              public Form1()
              {
                  InitializeComponent();
              }
          
              private void Form1\_Load(object sender, EventArgs e)
              {
                  Application.AddMessageFilter(this);
              }
          }
          

          }

          R Offline
          R Offline
          R Myers
          wrote on last edited by
          #4

          Thanks! That worked great! R.Myers

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups