ComponentOne C1Calendar:添加图片到节假日

发布时间:2013/01/07 00:01 发布者:iceman

返回博客中心

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


关于葡萄城

赋能开发者!葡萄城是专业的集开发工具、商业智能解决方案、低代码开发平台于一身的软件和服务提供商,为超过 75% 的全球财富 500 强企业提供服务。葡萄城专注控件软件领域30年,希望通过模块化的开发控件、灵活的低代码应用开发平台等一系列开发工具、解决方案和服务,帮助开发者快速响应复杂多变的业务需求,最大程度地发挥开发者的才智和潜能,让开发者的 IT 人生更从容更美好。

了解详情,请访问葡萄城官网