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
  1. Home
  2. General Programming
  3. C#
  4. NumericUpDown Mouse Wheel

NumericUpDown Mouse Wheel

Scheduled Pinned Locked Moved C#
csharphelp
4 Posts 3 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.
  • C Offline
    C Offline
    cooltoad123
    wrote on last edited by
    #1

    Hallo, I am working with numericUpDown control in .net c#. The value of numericupdown changes on mouse wheel depending on number of spins mentioned in control panel->mouse->wheel. I want to overide this function such that value of numericupdown should not depend on control panel value.And always increment/decrement by value of 1.Irreespective of value mention at control panel, mouse wheel. I have used MouseWheel event numericUpDown1.MouseWheel += new MouseEventHandler(numericUpDown1_MouseWheel); private void numericUpDown1_MouseWheel(object sender, MouseEventArgs e) { if (e.Delta > 0) { numericUpDown1.Value = numericUpDown1.Value + 1; } else if (e.Delta < 0) { numericUpDown1.Value = numericUpDown1.Value - 1; } } but this snippet instead of incrementing/decrement by 1, adds 1 to the number of spins mention in control panel, mouse wheel . Any kind of help will be appreciated.

    A B 2 Replies Last reply
    0
    • C cooltoad123

      Hallo, I am working with numericUpDown control in .net c#. The value of numericupdown changes on mouse wheel depending on number of spins mentioned in control panel->mouse->wheel. I want to overide this function such that value of numericupdown should not depend on control panel value.And always increment/decrement by value of 1.Irreespective of value mention at control panel, mouse wheel. I have used MouseWheel event numericUpDown1.MouseWheel += new MouseEventHandler(numericUpDown1_MouseWheel); private void numericUpDown1_MouseWheel(object sender, MouseEventArgs e) { if (e.Delta > 0) { numericUpDown1.Value = numericUpDown1.Value + 1; } else if (e.Delta < 0) { numericUpDown1.Value = numericUpDown1.Value - 1; } } but this snippet instead of incrementing/decrement by 1, adds 1 to the number of spins mention in control panel, mouse wheel . Any kind of help will be appreciated.

      A Offline
      A Offline
      Anthony Mushrow
      wrote on last edited by
      #2

      Its because the numericUpDown's value gets changes by the mouse wheel, and then you handle the event for the mouss wheel and plus/minus 1 to the value. So your actually changing the value twice, if you see what i mean. What you need to do is something like this:

      if (e.Delta > 0) {
      numericUpDown1.Value -= e.Delta;
      numericUpDown1.Value++;
      }
      else if (e.Delta < 0) {
      numericUpDown1.Value += e.Delta;
      numericUpDiwn1.Value--;
      }

      That way you undo what the mouse wheel did, and then change the value yourself. EDIT:Never mind, that doesn't quite work, other way around, mouse event handled first, which may cause problems with minimum and maximum for the numreicUpDown. I'm not sure what you could do then. Even the ValueChanged event gets handled before the value has actually changed.

      My current favourite word is: Bacon!

      -SK Genius

      modified on Thursday, April 24, 2008 9:47 AM

      C 1 Reply Last reply
      0
      • A Anthony Mushrow

        Its because the numericUpDown's value gets changes by the mouse wheel, and then you handle the event for the mouss wheel and plus/minus 1 to the value. So your actually changing the value twice, if you see what i mean. What you need to do is something like this:

        if (e.Delta > 0) {
        numericUpDown1.Value -= e.Delta;
        numericUpDown1.Value++;
        }
        else if (e.Delta < 0) {
        numericUpDown1.Value += e.Delta;
        numericUpDiwn1.Value--;
        }

        That way you undo what the mouse wheel did, and then change the value yourself. EDIT:Never mind, that doesn't quite work, other way around, mouse event handled first, which may cause problems with minimum and maximum for the numreicUpDown. I'm not sure what you could do then. Even the ValueChanged event gets handled before the value has actually changed.

        My current favourite word is: Bacon!

        -SK Genius

        modified on Thursday, April 24, 2008 9:47 AM

        C Offline
        C Offline
        cooltoad123
        wrote on last edited by
        #3

        Thanks for your effort and help :).

        1 Reply Last reply
        0
        • C cooltoad123

          Hallo, I am working with numericUpDown control in .net c#. The value of numericupdown changes on mouse wheel depending on number of spins mentioned in control panel->mouse->wheel. I want to overide this function such that value of numericupdown should not depend on control panel value.And always increment/decrement by value of 1.Irreespective of value mention at control panel, mouse wheel. I have used MouseWheel event numericUpDown1.MouseWheel += new MouseEventHandler(numericUpDown1_MouseWheel); private void numericUpDown1_MouseWheel(object sender, MouseEventArgs e) { if (e.Delta > 0) { numericUpDown1.Value = numericUpDown1.Value + 1; } else if (e.Delta < 0) { numericUpDown1.Value = numericUpDown1.Value - 1; } } but this snippet instead of incrementing/decrement by 1, adds 1 to the number of spins mention in control panel, mouse wheel . Any kind of help will be appreciated.

          B Offline
          B Offline
          bscaer
          wrote on last edited by
          #4

          See this post for answer: http://answers.yahoo.com/question/index?qid=20080820123925AAGeohi[^]

          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