问题
I have a vb.net Windows Forms app using the 4.0 framework. When I run the application on an XP machine, the color of my controls all match what the are set to in my IDE, which is also an XP machine.
When I run this application on a Windows 7 machine, the colors are all changed.
Any ideas why this is and how I can make Windows 7 match my Development machine?
David
回答1:
Windows forms are going to take on whatever "theme" the machine they are running on has enabled - which is by design. Honestly, it wouldn't make sense for a windows form running on Windows 7 to look like an XP windows form. Could you give some sort of context for why you want your windows form to look like it's always running on XP?
回答2:
You can use the BackColor property of the button to change the background color. The ForeColor property will change the text color.
Edit: added the below after playing around some.
Try ensuring the "UseVisualStyleBackColor" property on your button is set to False. Playing around I noticed that when this is true, the system ignores my background color selection and uses the machine default. When False, my background color was used.
回答3:
I found this too. My VB6 project was fine in Windows XP. I just moved to Windows 7 and copied the project folder to this machine. My splashscreen backcolour was supposed to be white but it was black now. The backcolour had been set to &H80000009& which was white in winXP but in Windows 7 it gives black. So I changed backcolour to &H80000005& and it is now white again.
来源:https://stackoverflow.com/questions/8127597/windows-forms-color-variation-between-windows-7-and-xp