Not showing back color in UserControl in my calendar

Anonymous
2023-05-03T23:31:24.79+00:00

calendar

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.
5,115 questions
C#
C#
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.
10,922 questions
C++
C++
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.
3,729 questions
{count} votes

Accepted answer
  1. Viorel 117.3K Reputation points
    2023-05-04T07:10:08.3866667+00:00

    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

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.