This documentation is archived and is not being maintained.

PropertyDescriptor.SetValue Method

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

[Visual Basic]
Public MustOverride Sub SetValue( _
   ByVal component As Object, _
   ByVal value As Object _
public abstract void SetValue(
 object component,
 object value
public: virtual void SetValue(
 Object* component,
 Object* value
) = 0;
public abstract function SetValue(
   component : Object,
 value : Object


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


Typically, this method is implemented through reflection.

This method creates a DesignerTransaction automatically in the following order:

  1. The method calls IDesignerHost.CreateTransaction to create a new DesignerTransaction object to represent the changes.
  2. The method calls IComponentChangeService.OnComponentChanging 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 IComponentChangeService.OnComponentChanged 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 invalid, 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.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

See Also

PropertyDescriptor Class | PropertyDescriptor Members | System.ComponentModel Namespace | PropertyDescriptor