i need help whit the numericUpDown
I tried many ways but first let me explain the objective of the
control
1 - range from 1 to 100
2 -the person can enter higher value that 100 but it put back to 100
and popup the person
3- when pressing up it goes to closest increment of 25 (25-50-75-100
are possible value)
4- when pressing down it goes to closest increment of 25 (75-50-25-1)
the first thing is that 1 next increment of 25 isnt 25 but 26
ok so i set on the value change is the value happen to be 26 set value
to 25.
by default problem 2 is solved by itself nearly because numeric value
under minimum set back to minimum and value over maximum set to
maximum. the popup i was able with the Keypress check the numeric.text
and test if it was higher than the maximum and i made the popup it
work fine
the problem is. when i manually change value it trigger the
valuechange and the click up or down also trigger it.
if anyone know how i can capture in the valuechange has been triggered
by the up and down button or not i would be able to test all this.
if i put in the value change :
if(numeric.value >0 && numeric.value <25)
{
numeric.value = 25;
}
it work to go up to closest 25 increment but if i type 19 for example
and want 19 it doesnt distinguish if i clicked up to go to 25 or if i
change the value to 19 for him both trigger the code but it work only
for 1.
Paul E Collins - 11 Oct 2007 23:04 GMT
> i need help whit the numericUpDown [...]
private bool _suspendHandler = false;
private void numeric_ValueChanged(object sender, EventArgs e)
{
if (!_suspendHandler && numeric.Value == 26)
{
_suspendHandler = true;
numeric.Value = 25;
_suspendHandler = false;
}
}
private void Form1_Load(object sender, EventArgs e)
{
numeric.Increment = 25;
numeric.Minimum = 1;
numeric.Maximum = 100;
numeric.ReadOnly = true; // disallow typing a value
}
Eq.
Paul E Collins - 11 Oct 2007 23:06 GMT
> i need help whit the numericUpDown [...]
private void numeric_ValueChanged(object sender, EventArgs e)
{
if (numeric.Value == 26)
{
numeric.Value = 25;
}
}
private void Form1_Load(object sender, EventArgs e)
{
numeric.Increment = 25;
numeric.Minimum = 1;
numeric.Maximum = 100;
numeric.ReadOnly = true; // disallow typing a value
}
Eq.
Family Tree Mike - 12 Oct 2007 03:36 GMT
The original post wants the ability to type values into the control.
Sorry, I cannot figure this one out either. There is no arrow click event.
Maybe if you can inherit a user control from NumericUpDown, you could figure
out the events to signal a user defined event to handle. That would be what
I would investigate...
> > i need help whit the numericUpDown [...]
>
[quoted text clipped - 15 lines]
>
> Eq.
Franck - 12 Oct 2007 13:48 GMT
the closer solution ive come to so far would be a textbox checking for
numeric value and reating myselft up and down button or a vertical
scrollbar if more look like the up and down button
not_a_commie - 12 Oct 2007 19:46 GMT
Nobody should ever use NumericUpDown. The control has major bugs on
handling focus and validation. Inherit from the NumericUpDownBase and
write your own.