Export (0) Print
Expand All

PropertyDescriptor.SetValue Method

When overridden in a derived class, sets the value of the component to a different value.

Namespace:  System.ComponentModel
Assembly:  System (in System.dll)

public abstract void SetValue(
	Object component,
	Object value
)

Parameters

component
Type: System.Object

The component with the property value that is to be set.

value
Type: System.Object

The new value.

Typically, this method is implemented through reflection.

This method creates a DesignerTransaction automatically in the following order:

  1. The method calls the IDesignerHost.CreateTransaction method to create a new DesignerTransaction to represent the changes.

  2. The method calls the IComponentChangeService.OnComponentChanging method to indicate that the transaction has begun and the changes are about to occur.

  3. The method resets the property to the value determined by this method's checking order.

  4. The method calls the IComponentChangeService.OnComponentChanged method to indicate that the changes have occurred.

  5. The method calls DesignerTransaction.Commit to indicate that the transaction is complete.

The purpose of the transaction is to support Undo and Redo functionality.

Notes to Inheritors

When you override this method, it should set the value of the property by invoking the appropriate "SetMyProperty" method that you need to implement. If the value specified is not valid, the component should throw an exception, which is passed up. You should design the property so that a "GetMyProperty" method (that you have implemented) following a "SetMyProperty" method returns the value passed in when the "SetMyProperty" method does not throw an exception.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft