Solved

monthCalendar BoldedDates/colored Dates

Posted on 2013-01-02
4
4,280 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
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

752 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