DataGridViewCell.GetEditedFormattedValue 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
傳回目前已格式化的儲存格值,不管儲存格是否處於編輯模式,而值是否尚未認可。
public:
System::Object ^ GetEditedFormattedValue(int rowIndex, System::Windows::Forms::DataGridViewDataErrorContexts context);
public object GetEditedFormattedValue (int rowIndex, System.Windows.Forms.DataGridViewDataErrorContexts context);
public object? GetEditedFormattedValue (int rowIndex, System.Windows.Forms.DataGridViewDataErrorContexts context);
member this.GetEditedFormattedValue : int * System.Windows.Forms.DataGridViewDataErrorContexts -> obj
Public Function GetEditedFormattedValue (rowIndex As Integer, context As DataGridViewDataErrorContexts) As Object
參數
- rowIndex
- Int32
儲存格的資料列索引。
- context
- DataGridViewDataErrorContexts
DataGridViewDataErrorContexts 值的位元組合,指定資料錯誤內容。
傳回
DataGridViewCell 目前的已格式化值。
例外狀況
指定的 rowIndex
小於 0 或大於控制項中資料列數減 1。
ColumnIndex 小於 0,表示儲存格是資料列行首儲存格。
格式化失敗,而且 DataError 控制項的 DataGridView 事件沒有處理常式,或是該處理常式將 ThrowException 屬性設定為 true
。 例外狀況物件通常可轉換成 FormatException 類型。
備註
如果儲存格處於編輯模式,這個方法會傳回編輯儲存格的目前值或編輯控制項。 否則,這個方法會將儲存格值轉換成 屬性所 FormattedValueType 指示之型別的對等顯示值。 這會引發 DataGridView.CellFormatting 事件,您可以處理以自訂值轉換。
如果格式設定失敗,就會 DataGridView.DataError 發生此事件。 如果這個事件沒有處理常式,或處理常式會將 DataGridViewDataErrorEventArgs.ThrowException 屬性設定為 true
,則會擲回例外狀況。
如果引數包含 ClipboardContent 值,覆寫這個方法的衍生類別通常會傳回儲存格值的 context
字串表示。
適用於
另請參閱
意見反應
https://aka.ms/ContentUserFeedback。
即將登場:在 2024 年,我們將逐步淘汰 GitHub 問題作為內容的意見反應機制,並將它取代為新的意見反應系統。 如需詳細資訊,請參閱:提交並檢視相關的意見反應