SelectionRangeConverter.CanConvertFrom Method (ITypeDescriptorContext, Type)

 

Determines if this converter can convert an object of the specified source type to the native type of the converter by querying the supplied type descriptor context.

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

public override bool CanConvertFrom(
	ITypeDescriptorContext context,
	Type sourceType
)

Parameters

context
Type: System.ComponentModel.ITypeDescriptorContext

A ITypeDescriptorContext that provides a format context.

sourceType
Type: System.Type

The source Type to be converted.

Return Value

Type: System.Boolean

true if the converter can perform the specified conversion; otherwise, false.

The SelectionRangeConverter class is specialized to convert between the types String and SelectionRange. As a result, the CanConvertFrom method returns true if the sourceType parameter is of type String. Otherwise, it defers the call to the base implementation of this method, TypeConverter.CanConvertFrom(ITypeDescriptorContext, Type).

Notes to Inheritors:

Override this method to provide your own conversion requirements.

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

.NET Framework
Available since 1.1
Return to top
Show: