Not showing back color in UserControl in my calendar

Jay-R Hayashi 166 Reputation points


Good day, as you can see in the image, at first May 4 2023 it's show the back color light blue but when I click next button for show other month and back to the present month the back color of UserControl not show.

As you can see the picture below, all of this code is running for my calendar. I don't know where is my mistake.

User's image

Please help me to fix this problem.

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
3,146 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
8,185 questions
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
2,895 questions
{count} votes

Accepted answer
  1. Viorel 94,511 Reputation points

    Try adding these lines to your buttons:

    DateTime today = DateTime.Today;
    if( year == today.Year && month = today.Month && i == today.Day ) ucdays.BackColor = Color.LightSkyBlue;

    To avoid code repetition, maybe you should create a common function.

    0 comments No comments

0 additional answers

Sort by: Most helpful