月历-禁用天数 [英] MonthCalendar - Disable days

查看:124
本文介绍了月历-禁用天数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio C#编写应用程序,并且正在使用Windows窗体.我需要用户能够从特定范围中选择日期(为此,我正在使用MinDateMaxDate),并且只能选择一周中的某些天.例如,我想禁用 Mondays .我正在使用MonthCalendar,但是我还没有找到禁用星期几的方法...可能吗?

I'm doing an application in C# with Visual Studio, and I'm using Windows Forms. I need the user to be able to select a date from a specific range (for this I'm using MinDate and MaxDate), and only some days of the week. For example, I want to disable Mondays. I'm using MonthCalendar, but I haven't found a way to disable days of the week... Is it possible?

推荐答案

您不能阻止用户在日历上选择日期.毫无疑问,抱怨并提供了更好的选择:

You can't stop the user from picking a date on the calendar. No trouble however complaining and offering a better choice:

private void monthCalendar1_DateChanged(object sender, DateRangeEventArgs e) {
    if (e.Start.DayOfWeek == DayOfWeek.Monday) {
        MessageBox.Show("I hate mondays");
        monthCalendar1.SelectionStart = e.Start.AddDays(1);
    }
}

使用BoldedDates属性可以使有效选择更加明显.

Use the BoldedDates property to make valid selections more obvious.

这篇关于月历-禁用天数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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