EnableVisualStyles Method

Application.EnableVisualStyles Method ()


Enables visual styles for the application.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

Public Shared Sub EnableVisualStyles

This method enables visual styles for the application. Visual styles are the colors, fonts, and other visual elements that form an operating system theme. Controls will draw with visual styles if the control and the operating system support 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().


Prior to the .NET Framework 2.0, the FlatStyle property of some controls, such as controls that derive from ButtonBase, had to be set to FlatStyle.System in order for the controls to be drawn with visual styles. In applications written with the .NET Framework 2.0, this is no longer necessary.


This method will have no effect for controls hosted in Internet Explorer.


Visual styles are only supported on these platforms.

The following code example demonstrates calling EnableVisualStyles in the Main function to enable visual styles for the application.

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

.NET Framework
Available since 1.1
Return to top
© 2015 Microsoft