Whilst working on a new Visual Basic 2005 application I was puzzled as to why the buttons were a pleasing XP-style rounded shape in the design environment but reverted to the old style rectangular shape when the application was run. After a bit of research I discovered the changes were required in order to get the XP style buttons at run time.
First, the Application.EnableVisualStyles method has to be called. More exactly it has to be called in Sub Main before Application.Run. Here is my Main.vb
Module Main
Sub main()
Application.EnableVisualStyles()
Application.Run(New MainForm())
End Sub
End Module
Secondly if you are running with an earlier version of Visual Studio then the FlatStyle property of the button has to be set to System. For VS 2005 you can leave this as Standard.
The information is provided 'as is'. It has worked for us,
but it may not work for you, so you use it at your own risk. We can't
enter into any correspondance about anything recorded here but please feel free to leave a comment.
Geographical coverage: AlphaOne Computing Services
provides a range of small business computer support and I.T. services throughout Sussex, including
Brighton, Hove, Shoreham, Worthing, Steyning, Burgess Hill,
Haywards Heath, Crawley, Lewes, Newhaven, Seaford, Uckfield and Eastbourne.
Comments
Thanks for this post, I too was wondering how to have the xp-style at runtime as well. I finally googled the right search query to stumble upon your site ;)
Posted by: Alex (31 Jul 2006 01:09)
Great stuff! There's an identical method in C#. Thanks.
Posted by: Terence (20 Aug 2006 17:39)
THANKS THIS WAS DRIVING ME NUTS!, I had to use several different search phrases to find your site.
Posted by: Jeff (05 Jan 2007 19:54)
Thank you so much. This was driving me nuts.
Posted by: GGill (13 Feb 2007 17:59)