Click here to Skip to main content
11,713,845 members (84,636 online)
Click here to Skip to main content

MonthCalendar Has a Problem When Displaying

, 4 Jan 2008 CPOL 15.8K 11
Rate this:
Please Sign up or sign in to vote.
MonthCalendar has a problem when displaying

Introduction

I encountered this problem when using System.Windows.Forms.MonthCalendar in my app. When the user changes and selects another month or year on MonthCalendar, this component displays incorrectly (some dates are missing or are in bold). I think it's a problem with the OnPaint() method of this component. It's really a Microsoft problem.

I asked my friends and searched on Google. Many people had faced the same problem, but had not found a solution yet.

Using the Code

I tested and saw that this problem occurred when calling Application.EnableVisualStyles() in the Program.cs file.

To resolve this problem, I have given two ideals here:

  1. You should write one custom control or component which inherits or wraps this MonthCalender of Microsoft and overrides the OnPaint() method. It will help you to have a better component which supports your business (such as select range date on MonthCalender).
  2. Add mcalSelectDate.SelectionEnd = mcalSelectDate.SelectionStart into MonthCalendar_DateChanged event.
private void mcalSelectDate_DateChanged(object sender, DateRangeEventArgs e)
{
     mcalSelectDate.SelectionEnd = mcalSelectDate.SelectionStart;
}

Hope my suggestions will help you.

History

  • 4th January, 2008: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

vietanh154
Software Developer (Senior) FPT Software JSC & VietSoftware International
Vietnam Vietnam
Programming is my hobby!
Vietanh154, vietanh154@yahoo.com or vietanh154gmail.com
Manager for Concat Group: http://nhómConcatGroup.vn/
Project Manager & Technical Leader for FPT Software JSC
Solution Architect & Technical Manager for VietSoftware International

Certification:
Microsoft Certified Application Developer For Microsoft .NET
Microsoft Certified Professional MCP 2.0 -- Certified Professional
Developing and Implementing Web Applications with Microsoft® Visual C#™ .NET and Microsoft® Visual Studio® .NET
Developing and Implementing Windows®-based Applications
with Microsoft® Visual C#™ .NET and Microsoft® Visual Studio® .NET
Developing XML Web Services and Server Components with
Microsoft Visual C# .NET and the Microsoft .NET Framework

You may also be interested in...

Comments and Discussions

 
Generalbai gi ma ngan the! Pin
matrix198411-Sep-08 23:31
membermatrix198411-Sep-08 23:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.150819.1 | Last Updated 4 Jan 2008
Article Copyright 2008 by vietanh154
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid