views:

276

answers:

2

Hi All,

I'm experimenting with the NumericUpDown control and have a question regarding its' flexibility. Basically, what I would like to do is display year ranges like so:

2006-2007; 2007-2008; 2008-2009; 2009-2010

Obviously, I would like the control to cycle through a range similar to this when the buttons are pushed.

If this is possible, the range would need to start at 2006-2007 and at the current year + 1 (i.e. 2009-2010; next year: 2010-2011).

Is this possible? Anyone have any examples? I currently have this set up as a combo box, but thought the NumericUpDown control would be nifty to use in this situation.

Thanks...

+3  A: 

Would a DomainUpDown control do what you want?

Andrew Kennan
Thanks, Andrew. That'll work just fine. :)
Robert
+1  A: 

Try putting a NumericUpDown next to a label on the form and resize so the value is not visible (this could be done within a user control) then in the ValueChanged event handler on the NumericUpDown:

private void numericUpDown1_ValueChanged(object sender, EventArgs e)
{
   int year = DateTime.Now.Year + (int)numericUpDown1.Value;
   label1.Text = String.Format("{0} - {1}", year, year + 1);
}
benPearce