Click here to Skip to main content
Licence CPOL
First Posted 3 Jan 2008
Views 11,912
Bookmarked 11 times

MonthCalendar Has a Problem When Displaying

By | 4 Jan 2008 | Article
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)

About the Author

vietanh154

Software Developer (Senior)
FPT Software JSC
Vietnam Vietnam

Member

Programming is my hobby!
Vietanh154, vietanh154@yahoo.com or vietanh154gmail.com or AnhDV@fsoft.com.vn
AnhDV, G2-D2, FPT Software JSC
 
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

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Generalbai gi ma ngan the! Pinmembermatrix198423:31 11 Sep '08  

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.

Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120517.1 | Last Updated 4 Jan 2008
Article Copyright 2008 by vietanh154
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid