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?
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.