Click here to Skip to main content
15,893,381 members
Articles / Programming Languages / C#
Article

MonthCalendar Has a Problem When Displaying

Rate me:
Please Sign up or sign in to vote.
2.12/5 (10 votes)
4 Jan 2008CPOL 20K   11   1
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.
C#
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)


Written By
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

Comments and Discussions

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

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

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