Application.EnableVisualStyles Method ()
Enables visual styles for the application.
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
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,must be called before creating any controls in the application; typically, is the first line in the Main function. A separate manifest is not required to enable visual styles when calling .
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 callingin 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.EnableVisualStyles() 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.Controls.Add(Me.button1) Me.Text = "Application.EnableVisualStyles Example" End Sub 'New End Class 'Form1 End Namespace 'VStyles
Available since 1.1