How to show Specific Dates in Bold in MonthCalendar Control

 
You can do highlight some specific dates such as holidays in MonthCalendar control. MonthCalendar control can display singular date or dates on a repeating basis in Bold type.

These controls provide us three basic properties for doing this these are as follows:

BoldedDates property: we can assign an array of bold dates. contains single dates in bold.
AnnuallyBoldedDates property : we can assign an array of bold dates that appear in bold every year.
MonthlyBoldedDates property: we can assign an array of bold dates that appear in bold every month.

We can set these properties with the help of properties windows as well as code

BoldedDates:

[vb.net]

  1. Private Sub BoldDates()
  2.         Dim holidayDate1 As Date = New DateTime(2011, 9, 25)
  3.         Dim holidayDate2 As Date = New DateTime(2011, 9, 30)
  4.         MonthCalendar1.AddBoldedDate(holidayDate1)
  5.         MonthCalendar1.AddBoldedDate(holidayDate2)
  6.  End Sub

—or—

  1.  Private Sub BoldDates()
  2.         MonthCalendar1.BoldedDates = New System.DateTime() {New System.DateTime(2011, 9, 25), New System.DateTime(2011, 9, 30)}
  3.     End Sub

[C#.net]

  1. private void BoldDates()
  2. {
  3.  System.DateTime holidayDate1 = new DateTime(2011, 9, 25);
  4.  System.DateTime holidayDate2 = new DateTime(2011, 9, 30);
  5.  MonthCalendar1.AddBoldedDate(holidayDate1);
  6.  MonthCalendar1.AddBoldedDate(holidayDate2);
  7. }

–or—

  1. private void BoldDates()
  2. {
  3.  MonthCalendar1.BoldedDates = new System.DateTime[] {
  4.   new System.DateTime(2011, 9, 25),
  5.   new System.DateTime(2011, 9, 30)};
  6. }

AnnuallyBoldedDates

determines which annual days are displayed in bold.

[vb.net]

  1.     Private Sub BoldAnuallyDates()
  2.         Dim holidayDate1 As Date = New DateTime(2011, 9, 25)
  3.         Dim holidayDate2 As Date = New DateTime(2011, 9, 30)
  4.         MonthCalendar1.AddAnnuallyBoldedDate(holidayDate1)
  5.         MonthCalendar1.AddAnnuallyBoldedDate(holidayDate2)
  6.     End Sub

–or—

  1.  Private Sub BoldAnuallyDates()
  2.         MonthCalendar1.AnnuallyBoldedDates= New System.DateTime() {New System.DateTime(2011, 9, 25), New System.DateTime(2011, 9, 30)}
  3.     End Sub

[C#.net]

  1. private void BoldAnuallyDates()
  2. {
  3.  System.DateTime holidayDate1 = new DateTime(2011, 9, 25);
  4.  System.DateTime holidayDate2 = new DateTime(2011, 9, 30);
  5.  MonthCalendar1.AddAnnuallyBoldedDate(holidayDate1);
  6.  MonthCalendar1.AddAnnuallyBoldedDate(holidayDate2);
  7. }

–or—

  1. private void BoldAnuallyDates()
  2. {
  3.  MonthCalendar1.AnnuallyBoldedDates= new System.DateTime[] {
  4.   new System.DateTime(2011, 9, 25),
  5.   new System.DateTime(2011, 9, 30)};
  6. }

MonthlyBoldedDates

determines which monthly days are displayed in bold.
[vb.net]

  1.     Private Sub BoldMonthlyDates()
  2.         Dim holidayDate1 As Date = New DateTime(2011, 9, 25)
  3.         Dim holidayDate2 As Date = New DateTime(2011, 9, 30)
  4.         MonthCalendar1.AddMonthlyBoldedDate(holidayDate1)
  5.         MonthCalendar1.AddMonthlyBoldedDate(holidayDate2)
  6.     End Sub

–or—

  1.  Private Sub BoldMonthlyDates()
  2.         MonthCalendar1.MonthlyBoldedDates= New System.DateTime() {New System.DateTime(2011, 9, 25), New System.DateTime(2011, 9, 30)}
  3.     End Sub

[C#.net]

  1. private void BoldMonthlyDates()
  2. {
  3.  System.DateTime holidayDate1 = new DateTime(2011, 9, 25);
  4.  System.DateTime holidayDate2 = new DateTime(2011, 9, 30);
  5.  MonthCalendar1.AddMonthlyBoldedDate(holidayDate1);
  6.  MonthCalendar1.AddMonthlyBoldedDate(holidayDate2);
  7. }

–or—

  1. private void BoldMonthlyDates()
  2. {
  3.  MonthCalendar1.MonthlyBoldedDates= new System.DateTime[] {
  4.   new System.DateTime(2011, 9, 25),
  5.   new System.DateTime(2011, 9, 30)};
  6. }

facebooktwittergoogle_plusredditpinterestlinkedinmail

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>