Can this control have a NumericUpDown?

I am experimenting with the NumericUpDown control and wondering about its flexibility. Basically, what I would like to do is display year ranges like this:

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

Obviously, I would like the control to go through a loop like this when the buttons are clicked.

If possible, the range should start in 2006-2007 and in the current year +1 (i.e. 2009-2010, next year: 2010-2011).

Is it possible? Does anyone have examples? I am currently configured as a combo box, but thought the NumericUpDown would be great to use in this situation.

Thank...

+2


source to share


2 answers


Will the DomainUpDown control do what you want?



+5


source


Try adding a NumericUpDown next to the label on the form and resizing so that the value is not visible (you can do this in a custom control), and then in the ValueChanged event handler on 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);
}

      

+1


source







All Articles