Change the color of a day in the Winforms Calendar control

1

I would be grateful if you could tell me if there is any way to change the color of a set of days in the Windows Forms Calendar control. It would be for the Framework 2.0

I have searched to see if there is any method or property that allows to put a specific date in color but the most I have seen is that it allows Bold to be placed, but it does not allow anything else. Maybe someone could have done this in some simple way.

    
asked by U. Busto 01.12.2016 в 12:28
source

2 answers

2

Unfortunately, this is not possible . The calendar component of winforms does not allow you to customize the calendar in any way in order to highlight the days. The only way you would do it would be creating a component of your own or inheriting from it and implementing the functionality by yourself.

However, this is not a common problem and there are already people who have encountered this problem and have given it the solution by creating a new component. If I had to recommend one, I would say that Another Month Calendar would meet your needs and is a recognized component and widely used.

    
answered by 24.04.2017 в 13:01
0

Use the DayRender event

                void DayRender(Object source, DayRenderEventArgs e) 
              {

                 if (!e.Day.IsOtherMonth && !e.Day.IsWeekend)
                    e.Cell.BackColor=System.Drawing.Color.Yellow;

                 if (e.Day.Date.Day == 18)
                    e.Cell.BackColor = Color.LightBlue;

              }
    
answered by 05.12.2016 в 14:44