VisualStyleRenderer.SetParameters 方法

定义

设置此 VisualStyleRenderer 的当前视觉样式元素。Sets the current visual style element of this VisualStyleRenderer.

重载

SetParameters(String, Int32, Int32)

将此 VisualStyleRenderer 设置给由指定的类、部件和状态值所表示的视觉样式元素。Sets this VisualStyleRenderer to the visual style element represented by the specified class, part, and state values.

SetParameters(VisualStyleElement)

将此 VisualStyleRenderer 设置给由指定 VisualStyleElement 所表示的视觉样式元素。Sets this VisualStyleRenderer to the visual style element represented by the specified VisualStyleElement.

SetParameters(String, Int32, Int32)

将此 VisualStyleRenderer 设置给由指定的类、部件和状态值所表示的视觉样式元素。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)

参数

className
String

Class 属性的新值。The new value of the Class property.

part
Int32

Part 属性的新值。The new value of the Part property.

state
Int32

State 属性的新值。The new value of the State property.

异常

当前视觉样式未定义 classNamepartstate 的组合。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.

注解

此方法在内部检查 IsSupported 属性的值。This method checks the value of the IsSupported property internally. 在调用此方法之前,应调用 IsElementDefined 方法,验证当前视觉样式是否为 classNamepartstate 参数指定的元素提供了定义。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.

SetParameters(VisualStyleElement)

将此 VisualStyleRenderer 设置给由指定 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)

参数

element
VisualStyleElement

一个 VisualStyleElement,指定 ClassPartState 属性的新值。A VisualStyleElement that specifies the new values of the Class, Part, and State properties.

异常

当前视觉样式未定义 elementelement 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.

示例

下面的代码示例演示如何使用 SetParameters(VisualStyleElement) 方法将 VisualStyleRenderer 设置为新的 VisualStyleElementThe following code example demonstrates how to use the SetParameters(VisualStyleElement) method to set a VisualStyleRenderer to a new VisualStyleElement. 此代码示例是为 VisualStyleRenderer 类概述提供的更大示例的一部分。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

注解

此方法在内部检查 IsSupported 属性的值。This method checks the value of the IsSupported property internally. 在调用此方法之前,应调用 IsElementDefined 方法来验证当前视觉样式是否为 element 参数所指定的元素提供了定义。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.

适用于