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.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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.
Please help me to fix this problem.
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.