DataGridViewImageCell.GetFormattedValue Method

Definition

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

protected:
 override System::Object ^ GetFormattedValue(System::Object ^ value, int rowIndex, System::Windows::Forms::DataGridViewCellStyle ^ % cellStyle, System::ComponentModel::TypeConverter ^ valueTypeConverter, System::ComponentModel::TypeConverter ^ formattedValueTypeConverter, System::Windows::Forms::DataGridViewDataErrorContexts context);
protected override object GetFormattedValue (object value, int rowIndex, ref System.Windows.Forms.DataGridViewCellStyle cellStyle, System.ComponentModel.TypeConverter valueTypeConverter, System.ComponentModel.TypeConverter formattedValueTypeConverter, System.Windows.Forms.DataGridViewDataErrorContexts context);
protected override object? GetFormattedValue (object? value, int rowIndex, ref System.Windows.Forms.DataGridViewCellStyle cellStyle, System.ComponentModel.TypeConverter? valueTypeConverter, System.ComponentModel.TypeConverter? formattedValueTypeConverter, System.Windows.Forms.DataGridViewDataErrorContexts context);
override this.GetFormattedValue : obj * int * DataGridViewCellStyle * System.ComponentModel.TypeConverter * System.ComponentModel.TypeConverter * System.Windows.Forms.DataGridViewDataErrorContexts -> obj
Protected Overrides Function GetFormattedValue (value As Object, rowIndex As Integer, ByRef cellStyle As DataGridViewCellStyle, valueTypeConverter As TypeConverter, formattedValueTypeConverter As TypeConverter, context As DataGridViewDataErrorContexts) As Object

Parameters

value
Object

The value to be formatted.

rowIndex
Int32

The index of the cell's parent row.

cellStyle
DataGridViewCellStyle

The DataGridViewCellStyle in effect for the cell.

valueTypeConverter
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
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
DataGridViewDataErrorContexts

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

Returns

An object that represents the formatted image.

Remarks

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.

Applies to

See also