ExpandableObjectConverter Class
Provides a type converter to convert expandable objects to and from various other representations.
Assembly: System (in System.dll)
Note: |
|---|
The HostProtectionAttribute attribute applied to this type or member has the following Resources property value: SharedState. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes. |
This class adds support for properties on an object to the methods and properties provided by TypeConverter. To make a type of property expandable in the PropertyGrid, specify this TypeConverter for standard implementations of GetPropertiesSupported and GetProperties. Mark child properties with the NotifyParentPropertyAttribute to ensure correct behavior in a PropertyGrid control.
Note: |
|---|
You should never access a type converter directly. Instead, call the appropriate converter by using TypeDescriptor. For more information, see the examples in the TypeConverter base class. |
For more information about type converters, see the TypeConverter base class and How to: Implement a Type Converter.
The following code example converts a variable of type Margins to a string variable.
The following code example demonstrates how to use the NotifyParentPropertyAttribute and the ExpandableObjectConverter class to create an expandable property on a custom control. This code example is part of a larger example provided for the NotifyParentPropertyAttribute class.
<TypeConverter(GetType(BorderAppearanceConverter))> _ Public Class BorderAppearance Private borderSizeValue As Integer = 1 Private borderColorValue As Color = Color.Empty <Browsable(True), NotifyParentProperty(True), EditorBrowsable(EditorBrowsableState.Always), DefaultValue(1)> _ Public Property BorderSize() As Integer Get Return borderSizeValue End Get Set If value < 0 Then Throw New ArgumentOutOfRangeException("BorderSize", value, "must be >= 0") End If If borderSizeValue <> value Then borderSizeValue = value End If End Set End Property <Browsable(True), NotifyParentProperty(True), EditorBrowsable(EditorBrowsableState.Always), DefaultValue(GetType(Color), "")> _ Public Property BorderColor() As Color Get Return borderColorValue End Get Set If value.Equals(Color.Transparent) Then Throw New NotSupportedException("Transparent colors are not supported.") End If If borderColorValue <> value Then borderColorValue = value End If End Set End Property End Class
System.ComponentModel.TypeConverter
System.ComponentModel.ExpandableObjectConverter
System.Drawing.IconConverter
System.Drawing.Printing.MarginsConverter
System.Windows.Forms.ColumnHeaderConverter
System.Windows.Forms.ListViewItemConverter
System.Windows.Xps.Serialization.ColorTypeConverter
System.Windows.Xps.Serialization.FontTypeConverter
System.Windows.Xps.Serialization.ImageSourceTypeConverter
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note: