How to simulate Wrap in NumericUpDown control

G

Guest

Hi All,
I have a Pocket PC appln. with compact framework 1.0,
I want to wrap the values when value reaches the max. like DomainUpDown
control in NumericUpDown control

Any there to help me out.

rrgds,
Vinay
 
S

Sergey Bogdanov

Try to handle NumericUpDown.ValueChanged event with:

if (numericUpDownCtrl.Value == numericUpDownCtrl.Maximum)
numericUpDownCtrl.Value = numericUpDownCtrl.Minimum;

Because of Maximum value always resets to Minimum and can not be set you
should set it to Maximum + 1.

Best regards,
Sergey Bogdanov
http://www.sergeybogdanov.com
 
G

Guest

Thanks Sergey Bogdanov,
well I have specific reqts. where i need to roll up the values

more clearly
if the NumericUpDown.Value = max then
NumericUpDown.Value = reset to min

and if NumericUpDown.Value = Min (0)
then NumericUpDown.Value = max

i was a not able to achive,as i could not handle which arrow (up/down) is
clicked/selected .... is there any way....?
 
D

Daniel Moth

You could store the last value and compare against it with the new value to
determine the direction (up or down) the user is going...

Cheers
Daniel
 
G

Guest

Daniel,
Say here in updowncontrol i want to set max as 23 and min as 0
i could easily make a roolup when the value reaches 23 comparing with 'value
but when value is 0 and i want to rollup i cannot check value < 0 as min
allowable value is 0. I was playing with some flags setting ...but i could
not get the soln.

any help..is appreciated
rgds,
Vinay
 
D

Daniel Moth

1. Declare a private class level int variable: oldValue.
2. Initialise it as form load to the value from the numericupdown control.
3. Everytime valuechanged is raised, check the current value from the
control against the oldValue.
4. Then store the new value in the oldValue (for next time round)

Step 3 gives you the direction (i.e. which button the user clicked).

If you are still having problems, post a small sample with the code you are
trying so I can suggest what needs modifying.

Cheers
Daniel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top