Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

detecting UP or DOWN of a NumericUpDown

Status
Not open for further replies.

JulianUK

Programmer
Apr 17, 2002
73
GB
afternoon / morning

I'm trying to detect which button (up or down) was fired during the ValueChanged event.

I can tantalisingly see the "pushed" property during debug in my local variables navigator, but can't seem to get at it.

What do I need to do?

Thanks

Julian
 
On the keypress or the keydown event, you should check it for "Keys.Up" and "Keys.Down". If the up or down keys are handled before the keypress is fired, you may need to overload the control to catch it.

Good Luck,
Kevin

- "The truth hurts, maybe not as much as jumping on a bicycle with no seat, but it hurts.
 
Thanks kmfna, but the keydown (or key..anything) events do not seem to fire upon up/down button press.

Those events fire upon actual keypress on the control. "Keys" doesn't seem to exist anyway.

I am using C# in Delphi 2005 if that makes a difference, but I don't think so.

Julian
PS: sorry for the delay in replying but I've been off having a family!
 

decimal prevValue=0;
private void numericUpDown1_ValueChanged(object sender, System.EventArgs e)
{
if (numericUpDown1.Value < prevValue)
{
MessageBox.Show("Down");
}
else if(numericUpDown1.Value > prevValue)
{
MessageBox.Show("Up");
}

prevValue = numericUpDown1.Value;

}
 
Thanks mbde

Unfortunately that's exactly the filthy fix I wrote in already.

Eurgh.

Saves overloading though I suppose.

Julian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top