Export (0) Print
Expand All
Expand Minimize

DataGridViewCell.GetClipboardContent Method

Retrieves the formatted value of the cell to copy to the Clipboard.

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in system.windows.forms.dll)

protected virtual Object GetClipboardContent (
	int rowIndex,
	bool firstCell,
	bool lastCell,
	bool inFirstRow,
	bool inLastRow,
	string format
)
protected Object GetClipboardContent (
	int rowIndex, 
	boolean firstCell, 
	boolean lastCell, 
	boolean inFirstRow, 
	boolean inLastRow, 
	String format
)
protected function GetClipboardContent (
	rowIndex : int, 
	firstCell : boolean, 
	lastCell : boolean, 
	inFirstRow : boolean, 
	inLastRow : boolean, 
	format : String
) : Object
Not applicable.

Parameters

rowIndex

The zero-based index of the row containing the cell.

firstCell

true to indicate that the cell is in the first column of the region defined by the selected cells; otherwise, false.

lastCell

true to indicate that the cell is the last column of the region defined by the selected cells; otherwise, false.

inFirstRow

true to indicate that the cell is in the first row of the region defined by the selected cells; otherwise, false.

inLastRow

true to indicate that the cell is in the last row of the region defined by the selected cells; otherwise, false.

format

The current format string of the cell.

Return Value

An Object that represents the value of the cell to copy to the Clipboard.

Exception typeCondition

ArgumentOutOfRangeException

rowIndex is less than 0 or greater than or equal to the number of rows in the control.

InvalidOperationException

The value of the cell's DataGridView property is a null reference (Nothing in Visual Basic).

-or-

ColumnIndex is less than 0, indicating that the cell is a row header cell.

Exception

Formatting failed and either there is no handler for the DataError event of the DataGridView control or the handler set the ThrowException property to true. The exception object can typically be cast to type FormatException.

This method is called by the DataGridView.GetClipboardContent method to retrieve a Clipboard-formatted value that represents the cell value.

The cell value is first retrieved in its display format from the GetEditedFormattedValue method. This may raise the DataGridView.CellFormatting event to format the value and the DataGridView.DataError event if formatting is unsuccessful.

The position-related parameters of this method indicate where this cell is located in the table of data representing the region defined by the selected cells in the DataGridView control. Depending on the cell's position, additional formatting information may be returned by this method along with the display-formatted cell value. For example, the HTML format for a cell in the first column of a row will include the tag that indicates the beginning of a row.

The supported Clipboard formats include DataFormats.Text, DataFormats.UnicodeText, DataFormats.Html, and DataFormats.CommaSeparatedValue.

For more information, see the Clipboard class.

Notes to Inheritors: Override this method to provide customized Clipboard values. For example, you could override this method to support copying values from custom cell types.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions

ADD
Show:
© 2014 Microsoft