【问题标题】:Want to Show Customized Datetimepicker as 'only Month and year' in Windows application(using C#)想要在 Windows 应用程序中将自定义的 Datetimepicker 显示为“仅月份和年份”(使用 C#)
【发布时间】:2019-11-03 10:47:23
【问题描述】:

DateTimePicker for only month and year in windows application in .NET

我只想显示 Month/Year DateTimePicker 控件以提供 UI 以选择任何年份的任何月份,但不显示使用 C# 的 .NET 的 Windows 应用程序中的日期/日期。

主要要求:

windows的datepicker中只需要显示月份和年份

【问题讨论】:

  • 我也有同样的问题。对于日历应用程序,我需要使用默认打开的年份视图来显示它以选择生日,所以下个月然后是日期。我尝试了很多东西,但没有任何效果。 .NET Framework WinForms 标准 DatetimePicker 似乎没有解决方案。您需要创建自己的控件或查找已创建的控件。我没有找到一个,但我没有搜索很多。

标签: c# .net windows


【解决方案1】:

使用 DateTimerPicker.Format 属性。检查MSDN

public void SetCustomFormat()
{
    // Set the Format type and the CustomFormat string.
    dateTimePicker1.Format = DateTimePickerFormat.Custom;
    dateTimePicker1.CustomFormat = "MM/yyyy";
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-08-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-28
    • 2011-06-11
    • 2023-03-09
    相关资源
    最近更新 更多