ColumnView.SetRowCellValue(Int32, GridColumn, Object) Method
Assigns a value to a specific cell.
Namespace: DevExpress.XtraGrid.Views.Base
Assembly: DevExpress.XtraGrid.v24.2.dll
NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation
#Declaration
public void SetRowCellValue(
int rowHandle,
GridColumn column,
object _value
)
#Parameters
Name | Type | Description |
---|---|---|
row |
Int32 | An integer value representing a row handle containing the desired cell. |
column | Grid |
A Grid |
_value | Object | An object representing the value to be assigned. |
#Remarks
The method does nothing in the following cases:
- the specified row handle is invalid or points to a group row;
- the specified column object is a null reference or belongs to another View.
- the specified row is a non-initialized New Item Row.
Changing a cell value raises the ColumnView.CellValueChanged event.
Note
Detail pattern Views do not contain data and they are never displayed within Xtra
- Grid
Control. - returns the top most View in a grid;Main View - Grid
Control. - returns the focused View;Focused View - Grid
Control. - returns the currently maximized View;Default View - the sender parameter of View specific events;
- Grid
View. - returns a detail clone View for a specific master row.Get Detail View
#Example
The code sample below iterates through grid records and reduces the “Price” column values by 10 percent.
private void UpdatePrice(DevExpress.XtraGrid.Views.Base.ColumnView View) {
// Obtain the Price column.
DevExpress.XtraGrid.Columns.GridColumn col = View.Columns.ColumnByFieldName("Price");
if (col == null) return;
View.BeginSort();
try {
// Obtain the number of data rows.
int dataRowCount = View.DataRowCount;
// Traverse data rows and change the Price field values.
for (int i = 0; i < dataRowCount; i++) {
object cellValue = View.GetRowCellValue(i, col);
double newValue = Convert.ToDouble(cellValue) * 0.9;
View.SetRowCellValue(i, col, newValue);
}
} finally { View.EndSort(); }
}
#Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the SetRowCellValue(Int32, GridColumn, Object) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.