【问题标题】:Can NumericUpDown control do this?NumericUpDown 控件可以做到这一点吗?
【发布时间】:2009-10-06 22:35:43
【问题描述】:

我正在试验 NumericUpDown 控件,并对其灵活性有疑问。基本上,我想做的是像这样显示年份范围:

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

显然,当按下按钮时,我希望控件在与此类似的范围内循环。

如果可能,范围需要从 2006-2007 年和当前年份 + 1 开始(即 2009-2010 年;明年:2010-2011 年)。

这可能吗?有人有任何例子吗?我目前将此设置为组合框,但认为在这种情况下使用 NumericUpDown 控件会很不错。

谢谢...

【问题讨论】:

    标签: c# winforms datetime numericupdown


    【解决方案1】:

    DomainUpDown 控件会做你想做的事吗?

    【讨论】:

      【解决方案2】:

      尝试在表单上的标签旁边放置 NumericUpDown 并调整其大小以使值不可见(这可以在用户控件中完成),然后在 NumericUpDown 上的 ValueChanged 事件处理程序中:

      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);
      }
      

      【讨论】:

        猜你喜欢
        • 2022-01-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多