DataGridViewCell.GetClipboardContent 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
擷取儲存格的已格式化的值,以複製到 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);
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 或是大於或等於控制項中的資料列數。
格式化失敗,而且 DataError 控制項的 DataGridView 事件沒有處理常式,或是該處理常式將 ThrowException 屬性設定為 true。 例外狀況物件通常可轉換成 FormatException 類型。
備註
此方法是由 方法呼叫, DataGridView.GetClipboardContent 以擷取代表儲存格值的剪貼簿格式值。
儲存格值會先從 GetEditedFormattedValue 方法擷取其顯示格式。 如果格式設定失敗, DataGridView.DataError 可能會引發 DataGridView.CellFormatting 事件來格式化值和事件。
這個方法的位置相關參數會指出這個儲存格位於資料表中,代表控制項中 DataGridView 所選儲存格所定義的區域。 根據儲存格的位置,這個方法可能會傳回其他格式資訊,以及顯示格式化的儲存格值。 例如,資料列第一欄儲存格的 HTML 格式會包含指出資料列開頭的標記。
支援的剪貼簿格式包括 DataFormats.Text 、 DataFormats.UnicodeText 、 DataFormats.Html 和 DataFormats.CommaSeparatedValue 。
如需詳細資訊,請參閱 Clipboard 類別。
給繼承者的注意事項
覆寫這個方法以提供自訂的剪貼簿值。 例如,您可以覆寫這個方法,以支援從自訂儲存格類型複製值。