Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

monthCalendar BoldedDates/colored Dates

Posted on 2013-01-02
4
Medium Priority
?
4,743 Views
Last Modified: 2013-01-02
I am using a monthCalendar to show year's holidays.
I prefer changing the BackColor of the specified dates but as far as I know its not possible with this control.
when trying to load holiday dates to the BoldedDates using a dynamic array with no success.
this is the code im using:
would love to get any working example.
0
Comment
Question by:Hagita
  • 2
  • 2
4 Comments
 
LVL 53

Accepted Solution

by:
Dhaest earned 1200 total points
ID: 38735831
This is not possible. There is no built-in way of customizing the way that individual days or dates are displayed on the MonthCalendar control.

You could owner-draw the control, but that's way too much work to justify. This will make you responsible for drawing the entire control yourself. Note that if you choose to go this route, the MonthCalendar control does not raise the Paint event because the base control sets the UserPaint bit to "False". You will have to subclass the control and override its OnPrint method instead.

I can't personally recommend any third-party controls that provide this level of customization, but a quick Google search does appear to turn up a few options:

http://www.codeproject.com/KB/selection/MonthCalendar.aspx
http://www.codeproject.com/KB/selection/MPK_Calendar.aspx
http://www.codeproject.com/KB/datetime/monthcalendar.aspx
0
 
LVL 53

Expert Comment

by:Dhaest
ID: 38735832
I'm not sure if you can Calendar1_DayRender event..

protected void Calendar1_DayRender(object sender, DayRenderEventArgs e)
    {
        if (! e.Day.IsOtherMonth )
        {
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    if ((dr["EventDate"].ToString() != DBNull.Value.ToString()))
                    {
                        DateTime dtEvent= (DateTime)dr["EventDate"];
                        if (dtEvent.Equals(e.Day.Date))
                        {
                            e.Cell.BackColor = Color.PaleVioletRed;
                        }
                    }
                }
        }
//If the month is not CurrentMonth then hide the Dates
        else
        {
                e.Cell.Text = "";
        }
    }
0
 

Author Comment

by:Hagita
ID: 38735892
Hi Dhaest, the DayRender event does not exist so its impossible.
 it is very strange since the functionality im looking for is common in other microsoft dev. tools like access etc'.
0
 

Author Closing Comment

by:Hagita
ID: 38736209
great sample codes -Thanks!
0

Featured Post

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

876 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question