VisualStyleInformation Class

Definition

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

C#
public static class VisualStyleInformation
Inheritance
VisualStyleInformation

Examples

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

C#
// This is a simple example for VisualStyleInformation that displays
// all of the visual style values in a ListView.

using System;
using System.Drawing;
using System.Text;
using System.Reflection;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;

namespace VisualStyleInformationSample
{
    public class Form1 : Form
    {
        private ListView listView1 = new ListView();

        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.Run(new Form1());
        }

        public Form1()
        {
            this.ClientSize = new Size(500, 500);
            this.Text = "VisualStyleInformation Property Values";

            listView1.Bounds = new Rectangle(new Point(10, 10),
                new Size(400, 300));
            listView1.View = View.Details;
            listView1.FullRowSelect = true;
            listView1.Sorting = SortOrder.Ascending;

            Type typeInfo = typeof(VisualStyleInformation);
            StringBuilder name = new StringBuilder();
            object propertyValue;

            // Declare an array of static/Shared property details for the
            // VisualStyleInformation class.
            PropertyInfo[] elementProperties =
                typeInfo.GetProperties(BindingFlags.Static | BindingFlags.Public);

            // Insert each property name and value into the ListView.
            foreach (PropertyInfo property in elementProperties)
            {
                name.Append(property.Name);
                propertyValue = property.GetValue(null,
                    BindingFlags.Static, null, null, null);
                ListViewItem newItem = new ListViewItem(name.ToString(), 0);
                newItem.SubItems.Add(propertyValue.ToString());
                listView1.Items.Add(newItem);
                name.Remove(0, name.Length);
            }

            // Create columns for the items and subitems.
            listView1.Columns.Add("Property", -2, System.Windows.Forms.HorizontalAlignment.Left);
            listView1.Columns.Add("Value", -2, System.Windows.Forms.HorizontalAlignment.Left);

            // Add the ListView to the control collection.
            this.Controls.Add(listView1);
        }
    }
}

Remarks

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

Properties

Author

Gets the author of the current visual style.

ColorScheme

Gets the color scheme of the current visual style.

Company

Gets the company that created the current visual style.

ControlHighlightHot

Gets the color that the current visual style uses to indicate the hot state of a control.

Copyright

Gets the copyright of the current visual style.

Description

Gets a description of the current visual style.

DisplayName

Gets the display name of the current visual style.

IsEnabledByUser

Gets a value indicating whether the user has enabled visual styles in the operating system.

IsSupportedByOS

Gets a value indicating whether the operating system supports visual styles.

MinimumColorDepth

Gets the minimum color depth for the current visual style.

Size

Gets a string that describes the size of the current visual style.

SupportsFlatMenus

Gets a value indicating whether the current visual style supports flat menus.

TextControlBorder

Gets the color that the current visual style uses to paint the borders of controls that contain text.

Url

Gets a URL provided by the author of the current visual style.

Version

Gets the version of the current visual style.

Applies to

Proizvod Verzije
.NET Framework 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10

See also