DataGridViewImageCell.GetFormattedValue 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
将图形当作要在单元格中显示的内容返回。
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
参数
- value
- Object
要格式化的值。
- rowIndex
- Int32
该单元格的父行索引。
- cellStyle
- DataGridViewCellStyle
对单元格有效的 DataGridViewCellStyle。
- valueTypeConverter
- TypeConverter
与值类型关联的 TypeConverter,它提供到格式化值类型的自定义转换;如果不需要此类自定义转换,则为 null
。
- formattedValueTypeConverter
- TypeConverter
与格式化值类型相关联的 TypeConverter,它提供从该值类型进行的自定义转换;如果不需要这种自定义转换,则为 null
。
- context
- DataGridViewDataErrorContexts
DataGridViewDataErrorContexts 值的按位组合,用于描述需要格式化值的上下文。
返回
表示格式化图像的对象。
注解
控件 DataGridView 调用此方法,将单元格值转换为 属性指示 FormattedValueType 的类型的等效显示值。 控件在 参数中 value
将单元格值传递给此方法。
context
如果参数值包含 ClipboardContent 值,此方法将返回 属性的值Description,以便复制到剪贴板。 否则,将 DataGridView.CellFormatting 发生 事件。
CellFormatting事件处理程序可以修改 value
和 cellStyle
。 但是,如果处理程序未将 DataGridViewCellFormattingEventArgs.FormattingApplied 属性设置为 true
,则此方法 value
使用 对象的格式设置属性 cellStyle
进行格式设置。
如果格式设置不成功,则会发生该 DataError 事件。 如果此事件没有处理程序,或者处理程序将 DataGridViewDataErrorEventArgs.ThrowException 属性设置为 true
,则会引发异常。
如果格式化成功,并且格式化值的类型与 属性的值 FormattedValueType 匹配,则此方法返回格式化值。 否则,此方法在 属性指示 FormattedValueType 的类型中返回标准错误图形。
适用于
另请参阅
反馈
https://aka.ms/ContentUserFeedback。
即将发布:在整个 2024 年,我们将逐步淘汰作为内容反馈机制的“GitHub 问题”,并将其取代为新的反馈系统。 有关详细信息,请参阅:提交和查看相关反馈