ComponentOne C1Calendar:添加图片到节假日

C1Calendar for Winforms 是一款全功能的 Outlook 风格日历,允许最终用户选择的当前日期或通过 C1Schedule 导航来的日期。根据当前所占空间大小,C1Clendar 可以一次性展示一个或者多个月份的日历。这篇博客将阐述如何定制 C1Calendar 的外观,实现在节假日日期上添加自定义图片。

发布于 2013/01/07 00:00

ComponentOne Enterprise

C1Calendar for Winforms 是一款全功能的 Outlook 风格日历,允许最终用户选择的当前日期或通过 C1Schedule 导航来的日期。根据当前所占空间大小,C1Clendar 可以一次性展示一个或者多个月份的日历。

这篇博客将阐述如何定制 C1Calendar 的外观,实现在节假日日期上添加自定义图片。

我们可以通过 C1.Win.C1Schedule.UI.CalendarTheme 来实现该功能,它代表 C1Calendar 控件的主题样式。

以下代码用于添加节日到 C1Calendar 中:

private void Form1_Load(object sender, EventArgs e)

{

// Add Holidays in the C1Calendar object

c1Calendar1.CalendarInfo.Holidays.AddRange(

new DateTime[] {new DateTime(2012,01,26),

new DateTime(2013,03,08),

new DateTime(2013,04,06),

new DateTime(2013,08,15),

new DateTime(2013,08,20),

new DateTime(2013,10,24),

new DateTime(2012,11,13),

new DateTime(2012,11,15),

new DateTime(2012,11,28),

new DateTime(2012,12,25)});

}

以下代码用于添加图片到以上节日中:

private void c1Calendar1_Paint(object sender, PaintEventArgs e)

{

    CalendarTheme t = c1Calendar1.Theme;

    // Assign the Holidays Collection to the Bolded Dates array in the Calendar

    c1Calendar1.BoldedDates =     c1Calendar1.CalendarInfo.Holidays.ToArray<DateTime>();

    // Add Background Image to the Bolded Dates Theme in the Calendar Themes

    t[7].BackImage = new Bitmap("../../Resources/Flag_of_India.svg.png");

}

效果图:

 

 

Download Sample CS

Download Sample VB

ComponentOne Enterprise | 下载试用

ComponentOne 是一套专注于企业 .NET开发、支持 .NET Core 平台,并完美集成于 Visual Studio 的第三方控件集,包含 300 多种 .NET开发控件,提供表格数据管理、数据可视化、报表和文档、日程安排、输入和编辑、导航和布局、系统提升工具等七大功能,被誉为“.NET开发的‘瑞士军刀’”。

ComponentOne 为您提供专业的产品咨询服务,并由技术支持工程师为您1对1解答。>> 发帖提问

相关产品
推荐相关案例
关注微信
葡萄城社区二维码

关注“葡萄城社区”

加微信获取技术资讯

加微信获取技术资讯

想了解更多信息,请联系我们, 随时掌握技术资源和产品动态