Cet article a fait l’objet d’une traduction automatique. Pour afficher l’article en anglais, activez la case d’option Anglais. Vous pouvez également afficher le texte anglais dans une fenêtre contextuelle en faisant glisser le pointeur de la souris sur le texte traduit.
Traduction
Anglais

Application.EnableVisualStyles méthode ()

 

Date de publication : novembre 2016

Active les styles visuels pour l'application.

Espace de noms:   System.Windows.Forms
Assembly:  System.Windows.Forms (dans System.Windows.Forms.dll)

public static void EnableVisualStyles()

This method enables visual styles for the application. Visual styles are the colors, fonts, and other visual elements that form an operating system theme. Controls will draw with visual styles if the control and the operating system support it. To have an effect, M:System.Windows.Forms.Application.EnableVisualStyles must be called before creating any controls in the application; typically, M:System.Windows.Forms.Application.EnableVisualStyles is the first line in the Main function. A separate manifest is not required to enable visual styles when calling M:System.Windows.Forms.Application.EnableVisualStyles.

System_CAPS_noteRemarque

Prior to the .NET Framework 2.0, the FlatStyle property of some controls, such as controls that derive from T:System.Windows.Forms.ButtonBase, had to be set to F:System.Windows.Forms.FlatStyle.System in order for the controls to be drawn with visual styles. In applications written with the .NET Framework 2.0, this is no longer necessary.

System_CAPS_noteRemarque

This method will have no effect for controls hosted in Internet Explorer.

WinXpFamily

Visual styles are only supported on these platforms.

The following code example demonstrates calling M:System.Windows.Forms.Application.EnableVisualStyles in the Main function to enable visual styles for the application.

using System;
using System.Drawing;
using System.Windows.Forms;

namespace VStyles
{
    public class Form1 : System.Windows.Forms.Form
    {

        private System.Windows.Forms.Button button1;

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

        public Form1()
        {
            this.button1 = new System.Windows.Forms.Button();
            this.button1.Location = new System.Drawing.Point(24, 16);
            this.button1.Size = new System.Drawing.Size(120, 100);
            this.button1.FlatStyle = FlatStyle.System;
            this.button1.Text = "I am themed.";

            // Sets up how the form should be displayed and adds the controls to the form.
            this.ClientSize = new System.Drawing.Size(300, 286);
            this.Controls.Add(this.button1);

            this.Text = "Application.EnableVisualStyles Example";

        }
    }
}

.NET Framework
Disponible depuis 1.1
Retour au début
Afficher: