Export (0) Print
Expand All

VisualStyleRenderer.IsElementDefined Method

Determines whether the specified visual style element is defined by the current visual style.

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

public static bool IsElementDefined (
	VisualStyleElement element
public static boolean IsElementDefined (
	VisualStyleElement element
public static function IsElementDefined (
	element : VisualStyleElement
) : boolean
Not applicable.



A VisualStyleElement whose class and part combination will be verified.

Return Value

true if the combination of the ClassName and Part properties of element are defined; otherwise, false.

Exception typeCondition


The operating system does not support visual styles.


Visual styles are disabled by the user in the operating system.


Visual styles are not applied to the client area of application windows.

This method checks the value of the IsSupported property internally.

The following code example demonstrates how to use the IsElementDefined method to determine whether to initialize a VisualStyleRenderer to a given VisualStyleElement. This code example is part of a larger example provided for the VisualStyleRenderer class overview.

// Set the VisualStyleRenderer to a new element.
private bool SetRenderer(VisualStyleElement element)
    if (!VisualStyleRenderer.IsElementDefined(element))
        return false;

    if (renderer == null)
        renderer = new VisualStyleRenderer(element);

    return true;

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

© 2014 Microsoft