VisualStyleInformation VisualStyleInformation VisualStyleInformation VisualStyleInformation Class

定义

提供有关操作系统的当前视觉样式的信息。Provides information about the current visual style of the operating system.

public ref class VisualStyleInformation abstract sealed
public static class VisualStyleInformation
type VisualStyleInformation = class
Public Class VisualStyleInformation
继承
VisualStyleInformationVisualStyleInformationVisualStyleInformationVisualStyleInformation

示例

下面的代码示例在VisualStyleInformation ListView控件中显示属性的值。The following code example displays the values of the VisualStyleInformation properties in a ListView control.

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

#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>
#using <System.dll>

using namespace System;
using namespace System::Drawing;
using namespace System::Text;
using namespace System::Reflection;
using namespace System::Windows::Forms;
using namespace System::Windows::Forms::VisualStyles;

namespace VisualStyleInformationSample
{
    public ref class StyleInfo : public Form
    {
    private:
        ListView^ displayStyleInfo;

    public:
        StyleInfo()
        {
            this->displayStyleInfo = gcnew ListView();
            this->ClientSize = System::Drawing::Size(500, 500);
            this->Text = "VisualStyleInformation Property Values";

            displayStyleInfo->Bounds = System::Drawing::Rectangle
                (System::Drawing::Point(10, 10),System::Drawing::Size(400, 300));
            displayStyleInfo->View = View::Details;
            displayStyleInfo->FullRowSelect = true;
            displayStyleInfo->Sorting = SortOrder::Ascending;

            Type^ typeInfo = VisualStyleInformation::typeid;
            Object^ propertyValue;

            // Declare an array of static/Shared property details for the
            // VisualStyleInformation class.
            array<PropertyInfo^>^ elementProperties = typeInfo->GetProperties
                (BindingFlags::Static | BindingFlags::Public);

            String^ name;
            // Insert each property name and value into the ListView.
            for each (PropertyInfo^ property in elementProperties)
            {
                name = property->Name;
                propertyValue = property->GetValue(nullptr,
                    BindingFlags::Static, nullptr, nullptr, nullptr);
                ListViewItem^ newItem = gcnew ListViewItem(name, 0);
                newItem->SubItems->Add(propertyValue->ToString());
                displayStyleInfo->Items->Add(newItem);
            }

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

            // Add the ListView to the control collection.
            this->Controls->Add(displayStyleInfo);
        }
    };
}

int main()
{
    Application::EnableVisualStyles();
    Application::Run(gcnew VisualStyleInformationSample::StyleInfo());
}
// 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);
        }
    }
}
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

注解

此类公开static了一些属性, 这些属性提供有关操作系统的当前视觉样式的详细信息。This class exposes static properties that provide details about the current visual style of the operating system.

属性

Author Author Author Author

获取当前视觉样式的作者。Gets the author of the current visual style.

ColorScheme ColorScheme ColorScheme ColorScheme

获取当前视觉样式的配色方案。Gets the color scheme of the current visual style.

Company Company Company Company

获取创建当前视觉样式的公司。Gets the company that created the current visual style.

ControlHighlightHot ControlHighlightHot ControlHighlightHot ControlHighlightHot

获取当前视觉样式用来指示控件的热状态的颜色。Gets the color that the current visual style uses to indicate the hot state of a control.

Copyright Copyright Copyright Copyright

获取当前视觉样式的版权。Gets the copyright of the current visual style.

Description Description Description Description

获取当前视觉样式的说明。Gets a description of the current visual style.

DisplayName DisplayName DisplayName DisplayName

获取当前视觉样式的显示名称。Gets the display name of the current visual style.

IsEnabledByUser IsEnabledByUser IsEnabledByUser IsEnabledByUser

获取指示用户是否已经在操作系统中启用视觉样式的值。Gets a value indicating whether the user has enabled visual styles in the operating system.

IsSupportedByOS IsSupportedByOS IsSupportedByOS IsSupportedByOS

获取指示操作系统是否支持视觉样式的值。Gets a value indicating whether the operating system supports visual styles.

MinimumColorDepth MinimumColorDepth MinimumColorDepth MinimumColorDepth

获取当前视觉样式的最小颜色深度。Gets the minimum color depth for the current visual style.

Size Size Size Size

获取一个描述当前视觉样式大小的字符串。Gets a string that describes the size of the current visual style.

SupportsFlatMenus SupportsFlatMenus SupportsFlatMenus SupportsFlatMenus

获取指示当前视觉样式是否支持平面菜单的值。Gets a value indicating whether the current visual style supports flat menus.

TextControlBorder TextControlBorder TextControlBorder TextControlBorder

获取当前视觉样式用来绘制包含文本的控件的边框的颜色。Gets the color that the current visual style uses to paint the borders of controls that contain text.

Url Url Url Url

获取由当前视觉样式的作者提供的 URL。Gets a URL provided by the author of the current visual style.

Version Version Version Version

获取当前视觉样式的版本。Gets the version of the current visual style.

适用于

另请参阅