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 control increment value change

NumericUpDown control increment value change

Scheduled Pinned Locked Moved C#
tutorialquestion
2 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.
  • B Offline
    B Offline
    Blubbo
    wrote on last edited by
    #1

    I was trying to determine on how to get this to work. When clicking on either up or down, its already set to 0.1 increment/decrement value. However, when shift key is pressed and clicking either up or down, the increment would change to 1.0 increment/decrement. I've done the coding but it delayed the increment change. When I shift-click, I had to click twice on the up button for the step value to change. What's the effective way to get the step value to change upon the shift-click is detected?

    OriginalGriffO 1 Reply Last reply
    0
    • B Blubbo

      I was trying to determine on how to get this to work. When clicking on either up or down, its already set to 0.1 increment/decrement value. However, when shift key is pressed and clicking either up or down, the increment would change to 1.0 increment/decrement. I've done the coding but it delayed the increment change. When I shift-click, I had to click twice on the up button for the step value to change. What's the effective way to get the step value to change upon the shift-click is detected?

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #2

      Create your own class, derived from NumericUpDown. Override the UpButton and DownButton methods:

      public class MyUpDown : NumericUpDown
      {
      public override void UpButton()
      {
      decimal save = Increment;
      if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
      {
      Increment *= 10;
      }
      base.UpButton();
      Increment = save;
      }
      public override void DownButton()
      {
      decimal save = Increment;
      if ((Control.ModifierKeys & Keys.Shift) == Keys.Shift)
      {
      Increment *= 10;
      }
      base.DownButton();
      Increment = save;
      }
      }

      Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      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