Spinner Control

G

Guy Noir

Hello.
Is there a way to make the spinner control "Rollover"

In other words, when we hit the down button on the control and reach
zero, if I press down again I would like it to rollover to 9.

And when I hit up and I finally come to 9, I would like the next up
press to hit 0.

I'm assuming I'll need to write the action myself, but I'm kind of at a
loss on how to handle this, or is there a default property that I can
modify to make this happen???

Thanks!!
Guy
 
D

Daniel

What's a spinner control? I checked through vis studio i can't find one?

Without knowing what it is though and assuming it acts like any other
control... just catch the click event on your up or down press and do:

//pseudo code on the up press

if(spinner.value >= 9)
spinner.value= 0;

//pseudo on the down
if(spinner.value <=0)
spinner.value= 9;

That help?
 
C

ChrisM

Maybe I've misunderstood your requirements,
but in dotNet 1.1, using the 'NumericUpDown' control as the Spinner,

This code should do:

private void numericUpDown1_ValueChanged(object sender, System.EventArgs e)
{
if (numericUpDown1.Value > numericUpDown1.Maximum-1)
numericUpDown1.Value = numericUpDown1.Minimum+1;
if (numericUpDown1.Value < numericUpDown1.Minimum+1)
numericUpDown1.Value = numericUpDown1.Maximum-1;
}

You would need to set the Minimum and Maximum to one lower and one higher
respectivley that the actual Min and Max you want the spinner to display.

Cheers,

Chris.
 
G

Guy Noir

Yesm sorrym numericupdown My bad :p
Thanks so much for the response. I'll give it a whirl.

-Guy
 
G

Guy Noir

So, I tried this. The problem that I came across is that when the
counter has already reached Zero, the value does not change and thus
the numericUpDown1_ValueChanged event is never fired?

Is there an event raised that tells us if the up or down control was
pressed?

I'm wanting to figure this out so I can write a user control that has
this method already included.

Thanks again.
-Guy
 
G

Guy Noir

I don't know why this was so hard for me but a little further googling
revealed that I can override the methods DownButton and UpButton

Thanks all for your input.

=Guy
 

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