代码之家  ›  专栏  ›  技术社区  ›  Brad

正在查找.NET WinForm的月/年选择器控件

  •  16
  • Brad  · 技术社区  · 17 年前

    我正在为.NET 2 WinForm查找月份选择器控件。

    1 回复  |  直到 17 年前
        1
  •  45
  •   Donut    17 年前

    使用 DateTimePicker . 你可以使用 custom format 只允许指定月份和年份。

    例子:

    DateTimePicker dateTimePicker1 = new DateTimePicker();
    dateTimePicker1.Format = DateTimePickerFormat.Custom;
    dateTimePicker1.CustomFormat = "MM yyyy";
    dateTimePicker1.ShowUpDown = true; // to prevent the calendar from being displayed
    

    见 this MSDN article 更多信息。

    编辑:
    若要阻止显示日历,请设置 ShowUpDown 属性上 日期输入框 到 true . 这将阻止显示日历和 CustomFormat )允许您使用向上/向下按钮仅设置月份和年份。

    推荐文章