1. In order for some controls to appear with the XP visual style, you have to set their FlatStyle property to System. Not all controls require this.
2. I used to use a manifest file to enable XP styles but I have found out (and don't know why it is hardly mentioned) that if you call Application.EnableVisualStyles() before calling Application.Run(some form), the next time you do run a form, it will
use XP styles.
I know that you should check to make sure that the proper libs are there for rendering the controls which is why I normally use Environment.OSVersion to make sure the user is running XP and enable the visual styles if that is the case.
Can someone inform me as to why I should use the manifest file over Application.EnableVisualStyles() other than that the manifest is configurable after compile time?
Application.EnableVisualStyles() - this did nothing I added it at the very start
But nothing changed. I changed the FlatStyle for the buttons from Standard to System and the buttons work fine. Some things are very strange.
And Manip, I completely agree with you. C# is very well made, VB.NET seems a bit shoddy and completely spoils everything that I thought VB stood for. The VB language was always simple (being based on BASIC and all) but the new reincarnation is over-complicated
(at least to read!).
Oh well, everyone to their own I guess.
Thanks for all the help guys. I'm sure I'll start many new threads when I need help
This might be a stupid question.. but if I enable XP styles will they work normally in Windows 2000?
It is odd that you can't get the visual styles to work. I just loaded up VS .NET, created a new WindowsApplication, added Application.EnableVisualStyles() to the main method on the line before Application.Run(new form1()), placed 2 buttons, 1 text box,
and one ComboBox on the form, set the button's FlatStyle property to System and ran the prog.
All controls were rendered using the XP style. No manifest files are included in the project.
If it helps you find where the problem lies, I'm using VS .NET 2003 Pro and running the .NET Framework v1.1. Dunno if it helps but I've applied every critical to low priority patch and fix from Windows Update including non-security items.
Also, I'm pretty sure that you can't get Windows XP styles on your progs if you use Windows 2000.
Actually the .NET SDK does contain all the FCL documentation, as well as, compilers and several other related tools. You can get it here:
This is enough to get started with, and the best part: FREE!
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.