Bewerken

Delen via


VisualStyleRenderer.SetParameters Method

Definition

Sets the current visual style element of this VisualStyleRenderer.

Overloads

SetParameters(String, Int32, Int32)

Sets this VisualStyleRenderer to the visual style element represented by the specified class, part, and state values.

SetParameters(VisualStyleElement)

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

SetParameters(String, Int32, Int32)

Sets this VisualStyleRenderer to the visual style element represented by the specified class, part, and state values.

public:
 void SetParameters(System::String ^ className, int part, int state);
public void SetParameters (string className, int part, int state);
member this.SetParameters : string * int * int -> unit
Public Sub SetParameters (className As String, part As Integer, state As Integer)

Parameters

className
String

The new value of the Class property.

part
Int32

The new value of the Part property.

state
Int32

The new value of the State property.

Exceptions

The combination of className, part, and state is not defined by the current visual style.

The operating system does not support visual styles.

-or-

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

-or-

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

Remarks

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 className, part, and state parameters.

Applies to

SetParameters(VisualStyleElement)

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

public:
 void SetParameters(System::Windows::Forms::VisualStyles::VisualStyleElement ^ element);
public void SetParameters (System.Windows.Forms.VisualStyles.VisualStyleElement element);
member this.SetParameters : System.Windows.Forms.VisualStyles.VisualStyleElement -> unit
Public Sub SetParameters (element As VisualStyleElement)

Parameters

element
VisualStyleElement

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

Exceptions

element is not defined by the current visual style.

The operating system does not support visual styles.

-or-

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

-or-

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

Examples

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 == nullptr)
        {
            renderer = gcnew VisualStyleRenderer(element);
        }
        else
        {
            renderer->SetParameters(element);
        }

        return true;
    }
// 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);
    }
    else
    {
        renderer.SetParameters(element);
    }

    return true;
}
' Set the VisualStyleRenderer to a new element.
Private Function SetRenderer(ByVal element As _
    VisualStyleElement) As Boolean

    If Not VisualStyleRenderer.IsElementDefined(element) Then
        Return False
    End If

    If renderer Is Nothing Then
        renderer = New VisualStyleRenderer(element)
    Else
        renderer.SetParameters(element)
    End If

    Return True
End Function

Remarks

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.

Applies to