VisualStyleElement Class


Identifies a control or user interface (UI) element that is drawn with visual styles.

Namespace:   System.Windows.Forms.VisualStyles
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)


type VisualStyleElement = class end


Gets the class name of the visual style element that this VisualStyleElement represents.


Gets a value indicating the part of the visual style element that this VisualStyleElement represents.


Gets a value indicating the state of the visual style element that this VisualStyleElement represents.

System_CAPS_pubmethodSystem_CAPS_staticCreateElement(String, Int32, Int32)

Creates a new visual style element from the specified class, part, and state values.


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)


Serves as the default hash function. (Inherited from Object.)


Gets the Type of the current instance.(Inherited from Object.)


Creates a shallow copy of the current Object.(Inherited from Object.)


Returns a string that represents the current object.(Inherited from Object.)

The VisualStyleElement class identifies a Windows control or user interface (UI) element that is defined by the current visual style of the operating system. A visual style element is defined in terms of class, part, and state:

  • The class identifies a group of related visual style elements that are typically drawn together. The class is specified by the ClassName property.

  • The part defines a discrete member of a class. The part is specified by the Part property.

  • The state describes the current visual state of the element defined by the class and part. The state is specified by the State property.

The System.Windows.Forms.VisualStyles namespace exposes hundreds of VisualStyleElement objects that represent the controls and user interface elements that can be defined by a visual style. These objects are exposed as static properties of nested classes of VisualStyleElement. For each property, the qualified name of the owning class represents the class and the part of the drawn element, and the property name represents the state of the element. For example, the VisualStyleElement.Button.PushButton.Pressed property returns a VisualStyleElement that can be used to draw a button in the pressed state with visual styles. The Pressed property name corresponds to the state, PushButton corresponds to the part, and Button identifies the class of the visual style element.

To draw a visual style element, create a VisualStyleRenderer, set it to the VisualStyleElement you wish to draw, and then call the DrawBackground method. To determine whether the current visual style provides a definition for a particular element, call the IsElementDefined method with the element as the argument.

VisualStyleElement and VisualStyleRenderer wrap the functionality of the visual styles API from the Windows Shell portion of the Windows Platform SDK. For more information on visual styles, see "Using Windows XP Visual Styles" in the Platform SDK portion of the MSDN Library at


Visual styles are supported only on these platforms.

The following code example is a complete application that provides a UI for browsing and drawing all of the VisualStyleElement objects exposed by the System.Windows.Forms.VisualStyles namespace. To view an element, use the ListView control on the left side of the window to navigate to the node that represents the state of the element you want to draw, and then click the node. This sample will draw the selected element only if the element is defined by the current visual style.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0

Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top