DataGridViewCell.GetClipboardContent 方法

定义

检索要复制到 <a0/> 的单元格的格式化值。

protected:
 virtual System::Object ^ GetClipboardContent(int rowIndex, bool firstCell, bool lastCell, bool inFirstRow, bool inLastRow, System::String ^ format);
protected virtual object GetClipboardContent(int rowIndex, bool firstCell, bool lastCell, bool inFirstRow, bool inLastRow, string format);
protected virtual object? GetClipboardContent(int rowIndex, bool firstCell, bool lastCell, bool inFirstRow, bool inLastRow, string format);
abstract member GetClipboardContent : int * bool * bool * bool * bool * string -> obj
override this.GetClipboardContent : int * bool * bool * bool * bool * string -> obj
Protected Overridable Function GetClipboardContent (rowIndex As Integer, firstCell As Boolean, lastCell As Boolean, inFirstRow As Boolean, inLastRow As Boolean, format As String) As Object

参数

rowIndex
Int32

包含单元格的行的从零开始的索引。

firstCell
Boolean

true 指示单元格位于所选单元格定义的区域的第一列中;否则,为 false.

lastCell
Boolean

true 指示单元格是所选单元格定义的区域的最后一列;否则,为 false.

inFirstRow
Boolean

true 指示单元格位于所选单元格定义的区域的第一行;否则,为 false.

inLastRow
Boolean

true 指示单元格位于所选单元格定义的区域的最后一行;否则,为 false.

format
String

单元格的当前格式字符串。

返回

一个 Object 表示要复制到该单元格 Clipboard的单元格的值。

例外

rowIndex 小于 0 或大于或等于控件中的行数。

单元格 DataGridView 属性的值为 null.

-或-

ColumnIndex 小于 0,表示单元格是行标题单元格。

格式设置失败,控件的事件没有处理程序DataError,或者处理程序将DataGridView属性ThrowException设置为 。true 异常对象通常可强制转换为类型 FormatException

注解

此方法由 DataGridView.GetClipboardContent 该方法调用,用于检索表示单元格值的剪贴板格式值。

单元格值首先从 GetEditedFormattedValue 方法的显示格式检索。 如果格式设置失败,可能会引发 DataGridView.CellFormatting 事件来设置值的格式和 DataGridView.DataError 事件。

此方法的位置相关参数指示此单元格位于数据表中,表示控件中 DataGridView 所选单元格定义的区域。 根据单元格的位置,此方法可能会返回其他格式信息以及显示格式的单元格值。 例如,行第一列中单元格的 HTML 格式将包含指示行开头的标记。

支持的剪贴板格式包括DataFormats.TextDataFormats.UnicodeTextDataFormats.HtmlDataFormats.CommaSeparatedValue

有关更多信息,请参见 Clipboard 类。

继承者说明

重写此方法以提供自定义的剪贴板值。 例如,可以重写此方法以支持从自定义单元格类型复制值。

适用于

另请参阅