This documentation is archived and is not being maintained.

Application.EnableVisualStyles Method

Note: This namespace, class, or member is supported only in version 1.1 of the .NET Framework.

Enables Windows XP visual styles for the application.

[Visual Basic]
Public Shared Sub EnableVisualStyles()
public static void EnableVisualStyles();
public: static void EnableVisualStyles();
public static function EnableVisualStyles();


This method enables Windows XP visual styles for the application. Controls will draw with visual styles if the control and the operating system supports it. To have an effect, EnableVisualStyles must be called before creating any controls in the application; typically, EnableVisualStyles is the first line in the Main function. A separate manifest is not required to enable visual styles when calling EnableVisualStyles.

Be sure to set the FlatStyle property to the FlatStyle.System value for the controls that support the FlatStyle property.

Note   This call will have no effect for controls in the browser.

XP Platform Note:  Visual styles are only supported on Windows XP Home Edition, Windows XP Professional, and Windows Server 2003.


[Visual Basic, C#, C++] The following example demonstrates calling EnableVisualStyles in the Main function to enable visual styles for the application.

[Visual Basic] 
Imports System
Imports System.Drawing
Imports System.Windows.Forms

Namespace VStyles
    ' Summary description for Form1.
    Public Class Form1
        Inherits System.Windows.Forms.Form

        Private button1 As System.Windows.Forms.Button

        <System.STAThread()> _
        Public Shared Sub Main()

            System.Windows.Forms.Application.Run(New Form1)
        End Sub 'Main

        Public Sub New()

            Me.button1 = New System.Windows.Forms.Button()
            Me.button1.Location = New System.Drawing.Point(24, 16)
            Me.button1.Size = New System.Drawing.Size(120, 100)
            Me.button1.FlatStyle = FlatStyle.System
            Me.button1.Text = "I am themed."

            ' Sets up how the form should be displayed and adds the controls to the form.
            Me.ClientSize = New System.Drawing.Size(300, 286)

            Me.Text = "Application.EnableVisualStyles Example"
        End Sub 'New 

    End Class 'Form1
End Namespace 'VStyles

using System;
using System.Drawing;
using System.Windows.Forms;

namespace VStyles
    public class Form1 : System.Windows.Forms.Form

        private System.Windows.Forms.Button button1;
        static void Main() 
            Application.Run(new Form1());

        public Form1()
            this.button1 = new System.Windows.Forms.Button();
            this.button1.Location = new System.Drawing.Point(24, 16);
            this.button1.Size = new System.Drawing.Size(120, 100);
            this.button1.FlatStyle = FlatStyle.System;
            this.button1.Text = "I am themed.";

            // Sets up how the form should be displayed and adds the controls to the form.
            this.ClientSize = new System.Drawing.Size(300, 286);

            this.Text = "Application.EnableVisualStyles Example";


#using <mscorlib.dll>
#using <System.dll>
#using <System.Windows.Forms.dll>
#using <System.Drawing.dll>

using namespace System;
using namespace System::Drawing;
using namespace System::Windows::Forms;

namespace VStyles {
public __gc class Form1 : public System::Windows::Forms::Form {

   System::Windows::Forms::Button*  button1;

   Form1() {
      this->button1 = new System::Windows::Forms::Button();
      this->button1->Location = System::Drawing::Point(24, 16);
      this->button1->Size = System::Drawing::Size(120, 100);
      this->button1->FlatStyle = FlatStyle::System;
      this->button1->Text = S"I am themed.";

      // Sets up how the form should be displayed and adds the controls to the form.
      this->ClientSize = System::Drawing::Size(300, 286);

      this->Text = S"Application::EnableVisualStyles Example";

int main() {
   Application::Run(new VStyles::Form1());

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Application Class | Application Members | System.Windows.Forms Namespace | FlatStyle