CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Sep 2005
    Location
    Pune,India
    Posts
    10

    Question How to check if Up/Down Button is pressed on NumericUpDown Control...

    Hi Friends,

    I would like to know that how to check whether up/down button was clicked on the NumericUpDown Control in .NET 2005.

    Any help would be greatly appreciated.

    With warm regards,

    KEDAR

  2. #2
    Join Date
    Oct 2005
    Location
    Islamabad, Pakistan
    Posts
    1,277

    Re: How to check if Up/Down Button is pressed on NumericUpDown Control...

    check this event NumericUpDown1_ValueChanged

  3. #3
    Join Date
    Sep 2005
    Location
    Pune,India
    Posts
    10

    Re: How to check if Up/Down Button is pressed on NumericUpDown Control...

    Thank you for your interest Mr. Anis Khan...

    But the ValueChanged event occurs irrespective of whether you click up button or down button.

    What i wanted to know is that if there is any way to determine specifically which button has been clicked.

    Actually i was expecting that there should have been some value in Event Arguments of the event ValueChanged indicating up/down button pressed.

    With warm regards,
    KEDAR

  4. #4
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: How to check if Up/Down Button is pressed on NumericUpDown Control...

    In my opinion, the ValueChanged is the only event you could use for this!

    There are methods
    NumericUpDown.UpButton
    NumericUpDown.DownButton

    but they cannot be used to determine which was clicked, only to "click" them through code - understand¿

    What you could perhaps do, is to have a variable indicating if the value of the numericupdown increases or decreases, because if the value increas, then automatically the up button was pressed, same with decrease.
    Based on that, you can do what you want to when someone clicks up or down

    I Hope I have been helpful.

  5. #5
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    1,080

    Re: How to check if Up/Down Button is pressed on NumericUpDown Control...

    You cannot determine that because you shouldn't really care. What matters in a NUD is the Value, so you should only care when that changes. If you want to know whether the Value has increased or decreased then store the old value in a variable and compare the two in the event handler. Note that the ValueChanged event is raised when the user manually types a value into the control and then moves focus, so it isn't just linked to the buttons.
    Tutorials: Home & Learn | Start VB.NET | Learn VB.NET | C# Station | GotDotNet | Games in VB.NET 101 Samples: 2002 | 2003 | 2005 | More .NET 2.0 (VB.NET, C#) Articles: VB.NET | C# | ASP.NET | MoreFree Components: WFC | XPCC | ElementsEx | VBPP | Mentalis | ADO.NET/MySQL | VisualStyles | Charting (NPlot, ZedGraph) | iTextSharp (PDF) | SDF (CF) ● Free Literature: VB 2005 (eBook) | VB6 to VB.NET (eBook) | MSDN Magazine (CHM format) ● Bookmarks: MSDN | WinForms .NET | ASP.NET | WinForms FAQ | WebForms FAQ | GotDotNet | Code Project | DevBuzz (CF) ● Code Converter: C#/VB.NET | VB.NET/C# | VS 2005 add-in

  6. #6
    Join Date
    Sep 2005
    Location
    Pune,India
    Posts
    10

    Smile Re: How to check if Up/Down Button is pressed on NumericUpDown Control...

    Hi Friends,

    I should thank you for all those valueable inputs.

    The reason i want to know which button is clicked is that i need to change the value of the interval in the pre-determined ranges like:-
    Value will increase by 1 in 1-20 and by 2 in 20-40 upto 60 and again when one clicks down button value should decrease by the same interval by which it has been increased in that range.

    I am thinking of using a variable to keep track of the previous value or simply abandon the idea of using the numeric control and use simple textbox and 2 buttons.

    With warm regards,
    KEDAR

  7. #7
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: How to check if Up/Down Button is pressed on NumericUpDown Control...

    Thanks for your eagerness to help. But I suppose after 7 yaers, it is safe to assume that this thread was resolved. Please do not revive old threads. There are plenty of active threads that also need help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured