DataGridView.UpdateCellValue(Int32, Int32) 方法

定義

強制控制項根據其新值更新指定位置的儲存格顯示,並套用目前有效的任何自動調整大小模式。Forces the control to update its display of the cell at the specified location based on its new value, applying any automatic sizing modes currently in effect.

public:
 void UpdateCellValue(int columnIndex, int rowIndex);
public void UpdateCellValue (int columnIndex, int rowIndex);
member this.UpdateCellValue : int * int -> unit
Public Sub UpdateCellValue (columnIndex As Integer, rowIndex As Integer)

參數

columnIndex
Int32

具有新值之儲存格的以零起始的資料行索引。The zero-based column index of the cell with the new value.

rowIndex
Int32

具有新值之儲存格的以零起始的資料列索引。The zero-based row index of the cell with the new value.

例外狀況

columnIndex 小於零,或大於控制項中的資料行數目減一。columnIndex is less than zero or greater than the number of columns in the control minus one.

-或--or- rowIndex 小於零,或大於控制項中的資料列數目減一。rowIndex is less than zero or greater than the number of rows in the control minus one.

備註

當您以虛擬模式維護資料格值,並在事件處理常式之外更新自訂資料快取中的值時,請使用這個方法 CellValuePushedUse this method when you maintain cell values in virtual mode and you update a value in your custom data cache outside of a CellValuePushed event handler.

這個方法會讓儲存格失效,強制控制項透過事件處理常式抓取新的值 CellValueNeeded ,並套用作用中的任何自動調整大小模式。This method invalidates the cell, forcing the control to retrieve the new value through the CellValueNeeded event handler and apply any automatic sizing modes that are in effect.

適用於

另請參閱