我怎样才能改变特定日期的MonthCalendar控件的颜色?控件、颜色、日期、MonthCalendar

2023-09-02 02:00:55 作者:久笙

我怎样才能改变特定日期的颜色MonthCalendar控件在VB.NET?

How can I change the color of certain dates in the MonthCalendar control in VB.NET?

例如,我需要改变1月21日的颜色为红色,周日橙等等...

For example, I need to change the color of Jan 21 to Red, Sundays to Orange and so on...

推荐答案

这是不可能的。有定制的方式,个别天或日期显示在没有内置的方式的MonthCalendar 控制。

This is not possible. There is no built-in way of customizing the way that individual days or dates are displayed on the MonthCalendar control.

您的可以的所有者绘制控件,但这是太多的工作来证明。这会让你负责绘制整个控制自己。请注意,如果你选择走这条路,在的MonthCalendar 控制不提高油漆事件,因为该基地控制集在 UserPaint 位为假。你将不得不继承控制并覆盖其OnPrint方法代替。

You could owner-draw the control, but that's way too much work to justify. This will make you responsible for drawing the entire control yourself. Note that if you choose to go this route, the MonthCalendar control does not raise the Paint event because the base control sets the UserPaint bit to "False". You will have to subclass the control and override its OnPrint method instead.

我不能亲自推荐任何第三方控件,提供定制化的这个水平,但快速谷歌搜索确实出现转了几个选项:

I can't personally recommend any third-party controls that provide this level of customization, but a quick Google search does appear to turn up a few options:

一个月日历 定制的MonthCalendar类型控制 的MonthCalendar日历 - 控制 Another Month Calendar Customizable MonthCalendar Type Control MonthCalendar Calendar - Control