Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: Current date on Windows MonthCalendar not bolding in Win 7 OS


13 Sep 2011   #1

Windows 7 Ultimate Service Pack 1 64-bit OS
 
 
Current date on Windows MonthCalendar not bolding in Win 7 OS

Gregarious greetings,

I work as a .NET Developer. I work on a Windows 7 PC that has Virtual PC/Windows XP mode.

My C# code in the Visual Studio 2005 Win app on the Virtual PC successfully bolds dates on a System.Windows.Forms.MonthCalendar control based on certain logic that pertains to the data in the SQL Server 2008 table. On the Virtual PC/Windows XP mode, when today's date (the current date) should be bolded and I run the app and open the MonthlyCalendar control, the current day 13 (for 13-SEP-2011) is shaded dark blue with the 13 in white font and when I click to a different date the dark blue shading disappears and the 13 becomes bolded in black like the other bolded dates for the month of September 2011. All is fine in the Windows XP mode.

When I install the installation file for this Windows application on the Windows 7, I run the app and open the MonthCalendar control. The 13 (for today, 13-SEP-2011) has a light blue shading and the 13 has blue font that does not look bolded like the other black bolded dates in this month. When I click to another date in this month, the 13 is not bolded like the other dark black bolded dates in this month.

I do not care at all about the Win 7/XP differences in the shading of the current date and the differences of the color of the rectangle around the current date.

I do care though that in Windows 7 the current date is not bolded when it should be.

I can provide the C# code if desired but it would seem that my C# code is not the problem since in Windows XP mode the current date is bolded when it should be and clearly appears as bold font whereas in Windows 7 the current date is not bolded. Please let me know if you want me to provide the C# code. There's C# code in our Class file from which I am inheriting and that uses the System.Windows.Forms.MonthCalendar control as well as in the file that retrieves data from the SQL Server 2008 table to determine if a date should be bolded and then bolds the date.

Yesterday, the 12th of this month, on Windows 7 the 12 on the MonthCalendar did not appear bolded while today it does. So it seems that this problem on Windows 7 is related to the current date.

I changed on Windows 7 the current Areo Win 7 theme to a couple of Basic themes (Win 7 Basic and Win Classic), but this did not help the problem. Changing the theme of course changed the way the MonthCalendar appears and the colors, but it did not cause the current date to be bolded in my Windows application on Windows 7.

This MonthCalendar control has a property that allows me to remove the circle/rectangle around the current date, but removing that circle or rectangle around the current date does not help bold the current date on Windows 7.

I have been researching on the Internet to see if any other Developer/Programmer has encountered this problem but have not found anybody who has. Since it would seem that my C# code is okay since it works on the Virtual PC/Windows XP mode, I thought that I would try to ask on a Windows 7 forum in case maybe someone here has heard of such a problem.

I extend to you my appreciation in advance for considering my post. Please let me know if I can provide further information.

Cordially,

Hviezdoslav

My System SpecsSystem Spec
.

20 Sep 2011   #2

Windows 7 Ultimate Service Pack 1 64-bit OS
 
 
I figured out how to solve the problem

In case this information will be helpful to anybody in the future, I finally determined the cause of the current date not bolding in Windows 7. I discovered the line of code that prevents the current date from bolding in Windows 7 even though the line of code does not prevent the current date from bolding in Virtual PC/Windows XP mode.

In the real Windows application, I searched for any code that might be the culprit and then tested in a lilí test application project. I used Visual Studio 2005 for my test application just as the real application was created in Visual Studio 2005. My review of the real app's code and my testing determined that when I comment out the following line of code in the real Windows app , the current date is bolded in Windows 7 whereas if I have this line of code the current date is not bolded in the System.Windows.Forms.MonthCalendar control in Windows 7:

this.calDate.MaxDate = System.DateTime.Today;



The name of the MonthCalendar control in this Windows app is calDate

Here is code from a lilí test app that shows how this line of code is the culprit. If you run the lilí test app with this line of code "this.monthCalendar1.MaxDate = System.DateTime.Today;" and then run the test app without this line of code on Windows 7, you will see that having this line of code prevents the current date from bolding on Windows 7. There is nothing in this Visual Studio 2005 project except a form and the MonthCalendar control on the form. There are no other controls on the form.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;


namespace ToTestCurrentDateBolding

{

publicpartialclassForm1 : Form

{


public Form1()

{

Application.EnableVisualStyles();
InitializeComponent();
this.monthCalendar1.MaxDate = System.DateTime.Today;
this.Load += new System.EventHandler(this.Form1_Load);

}


privatevoid Form1_Load(object sender, System.EventArgs e)
{

//Now I have added in this test project to set the MaxDate of the calendar control
//to current date to see if this affects the bolding of the current date on Windows 7.
//In our real app, we set the MaxDate to System.DateTime.Today.
//Using the following code, on Windows XP mode the current date is bolded still.
//On Windows 7, the current date is NOT bolded.
//SO HAVING THE LINE OF CODE "this.monthCalendar1.MaxDate = System.DateTime.Today;" IS
//THE REASON WHY THE CURRENT DATE IS NOT BOLDED IN WINDOWS 7!!! When I remove
//the line of code "this.monthCalendar1.MaxDate = System.DateTime.Today;" the
//current date IS BOLDED in Windows 7.
DateTime dt = DateTime.Now;
monthCalendar1.AddBoldedDate(dt);
monthCalendar1.UpdateBoldedDates();

//The following code works on BOTH Windows 7 and Windows XP mode
//when the Max Selection Count is the default 7 for the MonthCalendar
//control. I am trying this code when I change the Max Selection Count
//to 1 since this is the Maximum Selection Count in our real Windows application.
//With Max Selection Count set to 1, the current date is bolded on Windows XP mode.
//With Max Selection Count set to 1, on Windows 7 the current date DOES show as bold.
//DateTime dt = DateTime.Now;
//monthCalendar1.AddBoldedDate(dt);
//monthCalendar1.UpdateBoldedDates();


//This bolds the current date in Virtual PC/Windows XP mode.
//This ALSO bolds the current date in Windows 7.
//This code works on both Windows 7 and Virtual PC/Windows XP mode
//when I do NOT have the line of code Application.EnabledVisualStyles().
//DateTime dt = DateTime.Now;
//monthCalendar1.AddBoldedDate(dt);
//monthCalendar1.UpdateBoldedDates();

//When I DO have the line of code Application.EnabledVisualStyles(),
//this code does bold current date in Windows XP mode AND
//this code DOES bold the current date in Windows 7.
//DateTime dt = DateTime.Now;
//monthCalendar1.AddBoldedDate(dt);
//monthCalendar1.UpdateBoldedDates();

}
}
}

From the Form1.Designer.cs file, here is some code:

#region Windows Form Designer generated code

///<summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///</summary>
privatevoid InitializeComponent()
{
this.monthCalendar1 = new System.Windows.Forms.MonthCalendar();
this.SuspendLayout();
//
// monthCalendar1
//
this.monthCalendar1.Location = new System.Drawing.Point(210, 138);
this.monthCalendar1.MaxSelectionCount = 1;
this.monthCalendar1.Name = "monthCalendar1";
this.monthCalendar1.TabIndex = 0;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(628, 477);
this.Controls.Add(this.monthCalendar1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}

#endregion


So anyway, having the MaxDate property of the MonthCalendar control set to the current date prevents the bolding of the current date in Windows 7 even though setting the MaxDate property to current date does NOT prevent the bolding of the current date in Virtual PC/Windows XP mode. The MaxDate property of the MonthCalendar control gets or sets the maximum allowable date (for example, it sets the maximum allowable date that the user can select). In the real Windows app, the date range is for the calibration of probes on an oven control and of course it is not possible for a human being to calibrate the probes of an oven control in the future and therefore it is not necessary to allow the user to select a future date to see a report of the probe calibrations of the selected ovens for the selected date range. It does no harm though to remove this line of code and I am removing so that the current date will show as bold in Windows 7 if a calibration was done on that current date just like the current date showed in Windows XP mode/Virtual PC when the current date should be bolded per the data in the database.

Is this a bug in Windows 7? I do not know why setting the MaxDate of the MonthCalendar control to the current date would prevent the bolding of the current date in Windows 7 when it does NOT prevent the bolding of the current date in Virtual PC/Windows XP mode.

I just wanted to post this answer to the problem and the resolution in case anybody in the future will find it helpful.

Ciao,

Hviezdoslav
My System SpecsSystem Spec
Reply

 Current date on Windows MonthCalendar not bolding in Win 7 OS




Thread Tools




Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd

All times are GMT -5. The time now is 01:19 PM.
Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App
  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33