Solved

monthCalendar BoldedDates/colored Dates

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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

762 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

19 Experts available now in Live!

Get 1:1 Help Now