Spinner Control

  • Thread starter Thread starter Guy Noir
  • Start date Start date
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
 
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?
 
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.
 
Yesm sorrym numericupdown My bad :P
Thanks so much for the response. I'll give it a whirl.

-Guy
 
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
 
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
 
Back
Top