DataGridViewCell.GetClipboardContent(Int32, Boolean, Boolean, Boolean, Boolean, String) DataGridViewCell.GetClipboardContent(Int32, Boolean, Boolean, Boolean, Boolean, String) DataGridViewCell.GetClipboardContent(Int32, Boolean, Boolean, Boolean, Boolean, String) DataGridViewCell.GetClipboardContent(Int32, Boolean, Boolean, Boolean, Boolean, String) Method

定義

擷取儲存格的已格式化的值,以複製到 ClipboardRetrieves the formatted value of the cell to copy to the Clipboard.

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);
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 Int32 Int32 Int32

含儲存格之資料列的以零起始的索引。The zero-based index of the row containing the cell.

firstCell
Boolean Boolean Boolean Boolean

true 表示儲存格位於所選儲存格所定義之區域的第一個資料行中,否則為 falsetrue to indicate that the cell is in the first column of the region defined by the selected cells; otherwise, false.

lastCell
Boolean Boolean Boolean Boolean

true 表示儲存格位於所選儲存格所定義之區域的最後一個資料行中,否則為 falsetrue to indicate that the cell is the last column of the region defined by the selected cells; otherwise, false.

inFirstRow
Boolean Boolean Boolean Boolean

true 表示儲存格位於所選儲存格所定義之區域的第一個資料列中,否則為 falsetrue to indicate that the cell is in the first row of the region defined by the selected cells; otherwise, false.

inLastRow
Boolean Boolean Boolean Boolean

true 表示儲存格位於所選儲存格所定義之區域的最後一個資料列中,否則為 falsetrue to indicate that the cell is in the last row of the region defined by the selected cells; otherwise, false.

format
String String String String

儲存格的目前格式字串。The current format string of the cell.

傳回

Object,表示要複製到 Clipboard 之儲存格的值。An Object that represents the value of the cell to copy to the Clipboard.

例外狀況

rowIndex 小於 0 或是大於或等於控制項中的資料列數。rowIndex is less than 0 or greater than or equal to the number of rows in the control.

儲存格 DataGridView 屬性值為 nullThe value of the cell's DataGridView property is null.

-或--or- ColumnIndex 小於 0,表示儲存格是資料列行首儲存格。ColumnIndex is less than 0, indicating that the cell is a row header cell.

格式化失敗,而且 DataError 控制項的 DataGridView 事件沒有處理常式,或是該處理常式將 ThrowException 屬性設定為 trueFormatting failed and either there is no handler for the DataError event of the DataGridView control or the handler set the ThrowException property to true. 例外狀況物件通常可轉換成 FormatException 類型。The exception object can typically be cast to type FormatException.

備註

DataGridView.GetClipboardContent方法會呼叫這個方法來抓取代表儲存格值的剪貼簿格式值。This method is called by the DataGridView.GetClipboardContent method to retrieve a Clipboard-formatted value that represents the cell value.

資料格的值會先從GetEditedFormattedValue方法的顯示格式抓取。The cell value is first retrieved in its display format from the GetEditedFormattedValue method. 如果格式不成功DataGridView.CellFormatting ,這可能會引發事件來DataGridView.DataError格式化值和事件。This may raise the DataGridView.CellFormatting event to format the value and the DataGridView.DataError event if formatting is unsuccessful.

這個方法的位置相關參數會指出這個資料格所在的資料表,其代表DataGridView控制項中選取的儲存格所定義的區域。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. 例如,資料列第一個資料行中資料格的 HTML 格式會包含指出資料列開頭的標記。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.

支援的剪貼簿格式DataFormats.Text包括DataFormats.UnicodeTextDataFormats.Html、和DataFormats.CommaSeparatedValueThe supported Clipboard formats include DataFormats.Text, DataFormats.UnicodeText, DataFormats.Html, and DataFormats.CommaSeparatedValue.

如需詳細資訊,請參閱 Clipboard 類別。For more information, see the Clipboard class.

給繼承者的注意事項

覆寫這個方法,以提供自訂的剪貼簿值。Override this method to provide customized Clipboard values. 例如,您可以覆寫這個方法,以支援從自訂資料格類型複製值。For example, you could override this method to support copying values from custom cell types.

適用於

另請參閱