VisualStyleInformation Class
.NET Framework 3.0
Provides information about the current visual style of the operating system.
Namespace: System.Windows.Forms.VisualStyles
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Assembly: System.Windows.Forms (in system.windows.forms.dll)
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
Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Community Additions
ADD
Show: