OpacityConverter.ConvertFrom Method (ITypeDescriptorContext, CultureInfo, Object)


Converts the specified object to the converter's native type.

Namespace:   System.Windows.Forms
Assembly:  System.Windows.Forms (in System.Windows.Forms.dll)

public override object ConvertFrom(
	ITypeDescriptorContext context,
	CultureInfo culture,
	object value


Type: System.ComponentModel.ITypeDescriptorContext

A ITypeDescriptorContext that provides information about the context of a type converter.

Type: System.Globalization.CultureInfo

The locale information for the conversion.

Type: System.Object

The object to convert.

Return Value

Type: System.Object

An Object that represents the converted value.

Exception Condition

The object was not a supported type for the conversion.


value could not be properly converted to type Double.


The resulting converted value was less than zero percent or greater than one hundred percent.

The ConvertFrom method is specialized to convert String values that represent percentages or decimal fractions to their corresponding Double values, which represent the opacity as a percentage. Types other than String are passed to the base class implementation of this method.

Notes to Inheritors:

Override this method to provide your own conversion requirements.

You can use the context parameter to extract additional information about the environment this converter is being invoked from. The parameter may be null, so you should always verify the contents. Also, properties on the ITypeDescriptorContext may also return null.

.NET Framework
Available since 1.1
Return to top