I'm very picky when it comes to understanding a new language, and recently I've taken up learning C#. So I like to know everything that is going on when I create a new Application - in this case a new Windows Forms Application. I created one and was given some generated code from Visual Studio and one line was Application.EnableVisualStyles()
.
I did some research on MSDN and found this article: Application.EnableVisualStyles(). I performed the example that they presented expecting the button not to be visible when I commented out the said line. Nothing happened! It appeared that nothing changed. I know this is a very basic example but shouldn't something have changed? If this is so critical in the Main() procedure what exactly is it doing that I'm missing?
EnableVisualStyles() and run the application you can see all your controls rendered with current operating system theme settings. Means, If your operating system is Windows it will use the built-in Windows theaming to style controls and classic Windows look and feel if EnableVisualStyle() is commented.
System. Windows. Forms. dll is located in the folder C:\WINDOWS\Microsoft.NET\Framework\v2.
Yes it does, but you need have certain settings turned on in your OS otherwise you won't be able to see what it is.
Here are some screenshots of that same application on my system:
Application.EnableVisualStyles();
// Application.EnableVisualStyles();
If buttons in other applications look like the second screenshot then you will always see buttons un-themed regardless of whether you use Application.EnableVisualStyles()
, because they are turned off by the OS - the way to turn them back on depends on your OS but usually involves going to the Performance >> Visual Effects dialog.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With