VisualStyleState Enumeración

Definición

Especifica cómo se aplican estilos visuales a la aplicación actual.

Esta enumeración admite una combinación bit a bit de sus valores de miembro.

C#
public enum VisualStyleState
C#
[System.Flags]
public enum VisualStyleState
Herencia
VisualStyleState
Atributos

Campos

ClientAndNonClientAreasEnabled 3

Los estilos visuales se aplican a las áreas cliente y no cliente.

ClientAreaEnabled 2

Los estilos visuales sólo se aplican al área cliente.

NonClientAreaEnabled 1

Los estilos visuales sólo se aplican al área no cliente.

NoneEnabled 0

No se aplican estilos visuales a la aplicación.

Ejemplos

El ejemplo de código siguiente es un programa sencillo que aplica estilos visuales en cada una de las cuatro áreas especificadas por los VisualStyleState valores. Para habilitar estilos visuales en un área determinada, haga clic en el botón de opción (también conocido como botón de radio) que representa el área que desea habilitar y haga clic en el botón Actualizar VisualStyleState para observar los cambios en la ventana.

C#
using System;
using System.Drawing;
using System.Windows.Forms;
using System.Windows.Forms.VisualStyles;

namespace VisualStyleStateSample
{
    class Form1 : Form
    {
        Button button1 = new Button();
        RadioButton radioButton1 = new RadioButton();
        RadioButton radioButton2 = new RadioButton();
        RadioButton radioButton3 = new RadioButton();
        RadioButton radioButton4 = new RadioButton();

        public Form1()
        {
            button1.AutoSize = true;
            button1.Location = new Point(10, 10);
            button1.Text = "Update VisualStyleState";
            button1.Click += new EventHandler(button1_Click);

            radioButton1.Location = new Point(10, 50);
            radioButton1.AutoSize = true;
            radioButton1.Text = "Apply styles to client area only";

            radioButton2.Location = new Point(10, 70);
            radioButton2.AutoSize = true;
            radioButton2.Text = "Apply styles to nonclient area only";

            radioButton3.Location = new Point(10, 90);
            radioButton3.AutoSize = true;
            radioButton3.Text = "Apply styles to client and nonclient areas";

            radioButton4.Location = new Point(10, 110);
            radioButton4.AutoSize = true;
            radioButton4.Text = "Disable styles in all areas";

            this.Text = "VisualStyleState Test";
            this.Controls.AddRange(new Control[] { button1,  
                radioButton1, radioButton2, radioButton3, radioButton4});
        }

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

        void button1_Click(object sender, EventArgs e)
        {
            if (radioButton1.Checked)
            {
                Application.VisualStyleState =
                    VisualStyleState.ClientAreaEnabled;
            }
            else if (radioButton2.Checked)
            {
                Application.VisualStyleState =
                    VisualStyleState.NonClientAreaEnabled;
            }
            else if (radioButton3.Checked)
            {
                Application.VisualStyleState =
                    VisualStyleState.ClientAndNonClientAreasEnabled;
            }
            else if (radioButton4.Checked)
            {
                Application.VisualStyleState =
                    VisualStyleState.NoneEnabled;
            }

            // Repaint the form and all child controls.
            this.Invalidate(true);
        }
    }
}

Comentarios

Esta enumeración la usa la Application.VisualStyleState propiedad para especificar si los estilos visuales se aplican a las áreas cliente o no cliente de las ventanas de la aplicación.

Se aplica a

Producto Versiones
.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
Windows Desktop 3.0, 3.1, 5, 6, 7