Files
docs-desktop/dotnet-desktop-guide/framework/winforms/controls/how-to-change-monthcalendar-control-appearance.md
T
Andy De George c0ba284473 Initial winforms content migrated (#18)
* Merge winforms framework content to working branch (#14)

* Breadcrumb / TOC / Move net5 to net folder (#15)

* change path from net5 to net

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Mess with bread/toc

* Add .net 5 winforms placeholder article (#16)

* added some metadata and adjusted net5 placeholder

* corrections

* corrections

* corrections

* Test1

* Swapping landing page vs concept

* fix links

* Fix links

* Fix desc
2020-09-01 16:26:21 -07:00

5.4 KiB

title, ms.date, dev_langs, helpviewer_keywords, ms.assetid
title ms.date dev_langs helpviewer_keywords ms.assetid
Change MonthCalendar Control's Appearance 03/30/2017
csharp
vb
cpp
examples [Windows Forms], calendar controls
MonthCalendar control [Windows Forms], formatting display
d09b95c9-e108-4608-9b31-b9100c0677bf

How to: Change the Windows Forms MonthCalendar Control's Appearance

The Windows Forms xref:System.Windows.Forms.MonthCalendar control allows you to customize the calendar's appearance in many ways. For example, you can set the color scheme and choose to display or hide week numbers and the current date.

To change the month calendar's color scheme

To display the current date at the bottom of the control

  • Set the xref:System.Windows.Forms.MonthCalendar.ShowToday%2A property to true. The example below toggles between displaying and omitting today's date when the form is double-clicked.

    Private Sub Form1_DoubleClick(ByVal sender As Object, _  
    ByVal e As System.EventArgs) Handles MyBase.DoubleClick  
       ' Toggle between True and False.  
       MonthCalendar1.ShowToday = Not MonthCalendar1.ShowToday  
    End Sub  
    
    private void Form1_DoubleClick(object sender, System.EventArgs e)  
    {  
       // Toggle between True and False.  
       monthCalendar1.ShowToday = !monthCalendar1.ShowToday;  
    }  
    
    private:  
       System::Void Form1_DoubleClick(System::Object ^  sender,  
          System::EventArgs ^  e)  
       {  
          // Toggle between True and False.  
          monthCalendar1->ShowToday = !monthCalendar1->ShowToday;  
       }  
    

    (Visual C#, Visual C++) Place the following code in the form's constructor to register the event handler.

    this.DoubleClick += new System.EventHandler(this.Form1_DoubleClick);  
    
    this->DoubleClick += gcnew System::EventHandler(this,  
       &Form1::Form1_DoubleClick);  
    

To display week numbers

  • Set the xref:System.Windows.Forms.MonthCalendar.ShowWeekNumbers%2A property to true. You can set this property either in code or in the Properties window.

    Week numbers appear in a separate column to the left of the first day of the week.

    MonthCalendar1.ShowWeekNumbers = True  
    
    monthCalendar1.ShowWeekNumbers = true;  
    
    monthCalendar1->ShowWeekNumbers = true;  
    

See also