Not showing back color in UserControl in my calendar

BgnerNprg207 286 Reputation points
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.
4,832 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,588 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,617 questions
{count} votes

Accepted answer
  1. Viorel 114.2K 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