NumericUpDown ValueChanged not firing - scrollwheel+shift key pres

G

Graeme

Hello, really hope you guys can help.

I'm using a standard NumericUpDown control on a form, and trying to change
the increment depending if a Control.ModifierKeys is pressed when the mouse
scrollwheel is moved.

Default increment is 0.5

When Keys.Control is pressed and I roll the mousewheel, the increment is
adjusted to 5 and the ValueChanged event firest. Great.

But when Keys.Shift is pressed and I roll the mousewheel, the increment is
adjust to 1 BUT ValueChanged does not fire, so the value in NumericUpDown
doesn't get adjusted. Not so great. I'm really confused as to why Shift
would not cause ValueChanged to fire.

Here's the little bit of code :
private System.Windows.Forms.NumericUpDown numPrice;
this.numPrice = new System.Windows.Forms.NumericUpDown();

private void numPrice_MouseWheel(object sender,
System.Windows.Forms.MouseEventArgs e)
{
//check it's capturing

if (Control.ModifierKeys == Keys.Shift)
{
numPrice.Increment = 1;
}
else if (Control.ModifierKeys == Keys.Control)
{
numPrice.Increment = 5;
}
}

I guess I can manually fire ValueChanged after Shift and bodge it in some way?

Really starting to lose my mind over this...
 
G

Graeme

If anyone cares, I managed to work around this.

For some reason, Shift+Mousewheel wasn't firing the UpButton / DownButton
events. So I manually wrote this in the OnMouseWheel event

(I'm storing the wheelDelta as a variable on the form so I can tell if it's
changed by a certain number blah blah).

In addition, I set a variable mIsShiftPressed on the OnKeyPress event so I
can tell if shift was pressed.

If anyone has any idea why Shift+MouseWheel didn't really work, I'd love to
know. Framework 2.0

Anyway:

private void numPrice_MouseWheel(object sender,
System.Windows.Forms.MouseEventArgs e)
{

bool up = true;

wheelDelta += e.Delta;

//Somehow 'Shift' stops the mousewheel working correctly, so
fire this
//manually if mShiftIsPressed
if (mShiftIsPressed)
{
if (wheelDelta < 0)
{
up = false;
}

if (up)
{
numPrice.UpButton();
}
else
{
numPrice.DownButton();
}
}
wheelDelta = 0;

}
 
Top