如何在我的应用程序中显示月份选择日历 [英] How can i show month selection calendar in my app

查看:215
本文介绍了如何在我的应用程序中显示月份选择日历的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有兴趣显示12个月的清单,类似于datepicker的月份选择控制。但我不喜欢显示日期选择器来显示那个月份的日期,只有月份查看是可以的,所以我可以从列表中选择月份。

I am interested in showing list of 12 months like in similar way to datepicker's month selection control. But i don't like to show the date picker to show the dates of that month too... only month view is ok so that i can select month from the list.

我想要的输出:

my desired output:

推荐答案

我不完全确定我是否明白你在问什么。如果您想要显示没有附加选择器控件的月份日历,可以使用 MonthCalendar control

I'm not entirely sure if I understand what you're asking. If you want to show the month calendar without a picker control attached to it, you can use the MonthCalendar control.

看起来像这样(注意没有文本框和下拉箭头):

It looks like this (note the absence of the textbox and drop-down arrow):

  

  



如果您想知道是否有办法限制内容这显示在控制上只有几个月,而不是个人的月份,那么这不是不可能的。该控件不提供任何内置的设备。


If you're wondering if there's a way to limit the content that is displayed on the control to only the months themselves, rather than the individuals days of the month, then no that's not possible. The control does not provide any built-in facility for this.

但是,如果您想使用选择器控件,您可以限制它显示的值只有月份的名称。通过指定自定义格式字符串来执行此操作:

However, if you do want to use the picker control, you can limit the values it displays to only the name of the month. Do that by specifying a custom format string:

myDateTimePicker.Format = DateTimePickerFormat.Custom
myDateTimePicker.CustomFormat = "MMMM"

这将导致类似以下内容(请注意,下拉列表内容不变,但记录在选择器控件本身的信息仅限于该月份的名称):

This results in something like the following (notice that the drop-down content is unchanged, but the information that is recorded in the picker control itself is limited to the name of the month):

  

  

这篇关于如何在我的应用程序中显示月份选择日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆