VisualStyleRenderer.SetParameters Method (VisualStyleElement)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Sets this VisualStyleRenderer to the visual style element represented by the specified VisualStyleElement.

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

public void SetParameters(
	VisualStyleElement element


Type: System.Windows.Forms.VisualStyles.VisualStyleElement

A VisualStyleElement that specifies the new values of the Class, Part, and State properties.

Exception Condition

element is not defined by the current visual style.


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. Before calling this method, you should call the IsElementDefined method to verify that the current visual style provides a definition for the element specified by the element parameter.

The following code example demonstrates how to use the SetParameters(VisualStyleElement) method to set a VisualStyleRenderer to a new 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;

.NET Framework
Available since 2.0
Return to top