Solved

monthCalendar BoldedDates/colored Dates

Posted on 2013-01-02
4
3,907 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 300 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
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
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

947 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now