Export (0) Print
Expand All

VisualStyleInformation Class

Provides information about the current visual style of the operating system.

System.Object
  System.Windows.Forms.VisualStyles.VisualStyleInformation

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

'Declaration
Public NotInheritable Class VisualStyleInformation

The VisualStyleInformation type exposes the following members.

  NameDescription
Public propertyStatic memberAuthorGets the author of the current visual style.
Public propertyStatic memberColorSchemeGets the color scheme of the current visual style.
Public propertyStatic memberCompanyGets the company that created the current visual style.
Public propertyStatic memberControlHighlightHotGets the color that the current visual style uses to indicate the hot state of a control.
Public propertyStatic memberCopyrightGets the copyright of the current visual style.
Public propertyStatic memberDescriptionGets a description of the current visual style.
Public propertyStatic memberDisplayNameGets the display name of the current visual style.
Public propertyStatic memberIsEnabledByUserGets a value indicating whether the user has enabled visual styles in the operating system.
Public propertyStatic memberIsSupportedByOSGets a value indicating whether the operating system supports visual styles.
Public propertyStatic memberMinimumColorDepthGets the minimum color depth for the current visual style.
Public propertyStatic memberSizeGets a string that describes the size of the current visual style.
Public propertyStatic memberSupportsFlatMenusGets a value indicating whether the current visual style supports flat menus.
Public propertyStatic memberTextControlBorderGets the color that the current visual style uses to paint the borders of controls that contain text.
Public propertyStatic memberUrlGets a URL provided by the author of the current visual style.
Public propertyStatic memberVersionGets the version of the current visual style.
Top

This class exposes static properties that provide details about the current visual style of the operating system.

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

The following code example displays the values of the VisualStyleInformation properties in a ListView control.

Imports System
Imports System.Drawing
Imports System.Text
Imports System.Reflection
Imports System.Windows.Forms
Imports System.Windows.Forms.VisualStyles

Namespace VisualStyleInformationSample

    Public Class Form1
        Inherits Form
        Private listView1 As New ListView()

        <STAThread()> _
        Shared Sub Main()
            Application.EnableVisualStyles()
            Application.Run(New Form1())
        End Sub 

        Public Sub New()
            Me.Text = "VisualStyleInformation Property Values" 
            Me.AutoSize = True 

            With listView1
                .Bounds = New Rectangle(New Point(10, 10), New Size(400, 300))
                .View = View.Details
                .Sorting = SortOrder.Ascending
            End With 

            ' Get an array of property details for the 
            ' VisualStyleInformation class. 
            Dim typeInfo As Type = GetType(VisualStyleInformation)
            Dim elementProperties As PropertyInfo() = _
                typeInfo.GetProperties(BindingFlags.Static Or BindingFlags.Public)

            ' Use these variables to store the name and value of each property. 
            Dim propertyName As New StringBuilder()
            Dim propertyValue As Object 
            Dim prop As PropertyInfo

            For Each prop In elementProperties
                ' Get the name and value of the current property.
                propertyName.Append(prop.Name)
                propertyValue = prop.GetValue(Nothing, BindingFlags.Static, _
                    Nothing, Nothing, Nothing)
                ' Insert the property name and value into the ListView. 
                Dim newItem As New ListViewItem(propertyName.ToString(), 0)
                newItem.SubItems.Add(propertyValue.ToString())
                listView1.Items.Add(newItem)
                ' Clear the property name for the next iteration.
                propertyName.Remove(0, propertyName.Length)
            Next prop

            ' Create columns for the items and subitems.
            listView1.Columns.Add("Property", -1, _
                System.Windows.Forms.HorizontalAlignment.Left)
            listView1.Columns.Add("Value", -1, _
                System.Windows.Forms.HorizontalAlignment.Left)
            Me.Controls.Add(listView1)
        End Sub 
    End Class 
End Namespace

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft