Export (0) Print
Expand All

DataGridViewImageCell.GetFormattedValue Method

Returns a graphic as it would be displayed in the cell.

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

protected override Object GetFormattedValue(
	Object value,
	int rowIndex,
	ref DataGridViewCellStyle cellStyle,
	TypeConverter valueTypeConverter,
	TypeConverter formattedValueTypeConverter,
	DataGridViewDataErrorContexts context
)

Parameters

value
Type: System.Object

The value to be formatted.

rowIndex
Type: System.Int32

The index of the cell's parent row.

cellStyle
Type: System.Windows.Forms.DataGridViewCellStyle

The DataGridViewCellStyle in effect for the cell.

valueTypeConverter
Type: System.ComponentModel.TypeConverter

A TypeConverter associated with the value type that provides custom conversion to the formatted value type, or null if no such custom conversion is needed.

formattedValueTypeConverter
Type: System.ComponentModel.TypeConverter

A TypeConverter associated with the formatted value type that provides custom conversion from the value type, or null if no such custom conversion is needed.

context
Type: System.Windows.Forms.DataGridViewDataErrorContexts

A bitwise combination of DataGridViewDataErrorContexts values describing the context in which the formatted value is needed.

Return Value

Type: System.Object
An object that represents the formatted image.

The DataGridView control calls this method to convert a cell value into an equivalent display value of the type indicated by the FormattedValueType property. The control passes the cell value to this method in the value parameter.

If the context parameter value includes the ClipboardContent value, this method returns the value of the Description property for copying to the Clipboard. Otherwise, the DataGridView.CellFormatting event occurs.

A CellFormatting event handler can modify both value and cellStyle. If the handler does not set the DataGridViewCellFormattingEventArgs.FormattingApplied property to true, however, this method formats value using the formatting properties of the cellStyle object.

If formatting is unsuccessful, the DataError event occurs. If there is no handler for this event or the handler sets the DataGridViewDataErrorEventArgs.ThrowException property to true, an exception is thrown.

If formatting is successful and the type of the formatted value matches the value of the FormattedValueType property, this method returns the formatted value. Otherwise, this method returns a standard error graphic in the type indicated by the FormattedValueType property.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.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