LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Changing .net calendar cell background color

I'm attempting to use the .net MonthCalendar control in one of my vi's. My goal is to be able to programmatically "highlight" certain dates by changing the background color of the cell, or the color of the text (hopefully both).

 

I've tried modifying the "BackColor" and "ForeColor" properties, but I can't seem to get any changes to appear on the screen. In researching the class I came across this gem in the msdn website:

 

"Changing the ForeColor property may not affect the appearance of the MonthCalendar control, depending on the operating system and theme of the computer running the application. For example, changing the ForeColor property of the MonthCalendar control on Windows Vista with the Windows Aero theme does not affect the control appearance. "

 

...but I've tried in both Vista and XP machines to no avail.

 

 I hope I'm making an easily remidied beginner mistake (I've not done anything with .net controls in LabVIEW to this point), but can someone point me in the right direction or post a snippet of sample code illustrating the proper way for this to be done?

0 Kudos
Message 1 of 8
(3,919 Views)

Works for me. Are you keeping the VI running? Once the VI stops the colors revert back.

 

 

Message Edited by smercurio_fc on 01-27-2009 03:37 PM
Download All
0 Kudos
Message 2 of 8
(3,905 Views)

Yeah the VI was still running, and using your example isn't working either.

 

Blarg...

 

Upon loading our VI, though, I am getting a warning:

 

.NET assembly changed (1 warning)

 - Expected Assembly "System.Windows.Forms, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", but found "System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089."

 

 

Ideas? Anyone? 😞

0 Kudos
Message 3 of 8
(3,902 Views)

It seems you do not have .NET 1.1 installed. I simply placed the .NET MonthCalendar that is pre-packaged in the palette. The one that's there is the .NET 1.1 version. You can easily use the .NET 2.0 version instead. In fact, that's what happened when you opened the VI on your computer.

 

Why don't you post your VI so we can take a look at it? 

0 Kudos
Message 4 of 8
(3,898 Views)

Gladly, though there's not much to post. This issue is stopping my development before it gets started, unfortunately.

 

I'm beginning to suspect this is a Vista issue. Would you mind telling me if you're using Vista?

The comment on the MSDN info page seems to suggest there's a certain theme I have to set, but I've tried all the Vista themes to no avail.

Download All
0 Kudos
Message 5 of 8
(3,888 Views)
I am running XP SP2. When I ran your VI on my machine (which has .NET 2.0) the colors changed. Looks like it might very well be a Vista issue. You could try disabling Aero alltogether, but unfortunately I don't have a Vista machine on which to verify this.
0 Kudos
Message 6 of 8
(3,878 Views)

not working for me with win 7[labview 2012].!!!

any help.......?

0 Kudos
Message 7 of 8
(3,215 Views)

You will have to enable the 'VisualStylesState' of the 'System.Windows.Forms.Application' . You can use the VI snippet attached with this post. Remember to change the state and close the reference at the end of the use. Here is the link to the example from which I got this information: 

https://forums.ni.com/t5/Example-Programs/NET-MonthCalendar-Example-Changing-Visual-Properties-Using...

 Enable VisualStyleState Windows forms application.png

0 Kudos
Message 8 of 8
(2,632 Views)