How Do I Enable Visual Styles in My .NET Win Forms Application?
With the .NET Framework 1.1, however, things have become much easier.
At the bottom of this FAQ you'll find a link to an article that explains how to enable Visual Styles for the .NET Framework 1.0. It explains how to create a manifest file.
For version 1.1 of the .NET Framework, things are much easier. Instead of creating the manifest file, all you need to do is call Application.EnableVisualStyles() from within the Main method of your application.
If your application already contains a Main method, simply add the call to EnableVisualStyles() somewhere to that method. If you don't have a Main method yet, add the following code your application:
<System.STAThread()> Public Shared Sub Main()
// C# [STAThread]
static void Main()
Don't forget to change Form1 in the code above with the name of your StartUp form.
For controls that support the FlatStyle property, you have to set that property to FlatStyle.System. Other controls, like the ProgressBar, the TabControl and the TextBox will automatically apply the new Windows XP look. The following screen shot shows a Windows Form application with Visual Styles enabled. Notice the looks of the second button: even though Visual Styles are enabled, because the FlatStyle property of the button is set FlatStyle.Standard instead of FlatStyle.System, the button does not take on the new look:
Figure 1 - The Sample Application with Visual Styles Enabled
If you don't make the call to EnableVisualStyles() at all, or view the application on an older Windows version, like Windows 2000, this is what you'll see instead:
Figure 2 - The Sample Application without Visual Styles Enabled
Where to Next?
Wonder where to go next? You can post a comment on this article.
Links in this Document
|Written by||Imar Spaanjaars|
|Date Posted||04/13/2004 12:39|
|Date Last Updated||11/02/2020 16:31|
|Date Last Reviewed||12/07/2006 17:24|
|Listened to when writing||<strong>king o' cats</strong> by <strong>360's</strong> (Track 5 from the album: <strong>supernatural</strong>)|
Talk Back! Comment on Imar.Spaanjaars.Com
I am interested in what you have to say about this article. Feel free to post any comments, remarks or questions you may have about this article. The Talk Back feature is not meant for technical questions that are not directly related to this article. So, a post like "Hey, can you tell me how I can upload files to a MySQL database in PHP?" is likely to be removed. Also spam and unrealistic job offers will be deleted immediately.
When you post a comment, you have to provide your name and the comment. Your e-mail address is optional and you only need to provide it if you want me to contact you. It will not be displayed along with your comment. I got sick and tired of the comment spam I was receiving, so I have protected this page with a simple calculation exercise. This means that if you want to leave a comment, you'll need to complete the calculation before you hit the Post Comment button.
If you want to object to a comment made by another visitor, be sure to contact me and I'll look into it ASAP. Don't forget to mention the page link, or the Doc ID of the document.
Please correct the following errors:
Unfortunately, something went wrong and your message or comments have not been submitted successfully.
There's a fair chance things broke down because you tried to post something that looks like HTML. Things that look like HTML include (X)HTML, obviously, XML, ASP.NET markup and c# generics syntax as all of them use the < and > characters.
If that's the case, try altering your message and remove anything that looks like an angled bracket. You can replace them with [ and ] for example so you can still make it look like HTML to some extend.
If, on the other hand, you were trying to spam this web site, I am pretty glad I caught you in the act and stopped you from doing so ;-)
Also, please don't use links in your posts; I had to block them to filter out most of the junk mail I am receiving.