GridView.GetRowCellValue(Int32, String) Method
Returns the value of the specified cell, which is identified by the row handle and field name in the grid’s data source.
Namespace: DevExpress.XtraGrid.Views.Grid
Assembly: DevExpress.XtraGrid.v24.2.dll
NuGet Packages: DevExpress.Win.Grid, DevExpress.Win.Navigation
#Declaration
#Parameters
Name | Type | Description |
---|---|---|
row |
Int32 | An integer value representing the handle of the row in which the desired cell resides. Row handles are not data source indexes, see the Accessing Rows in Code. Row Handles section of the “Rows” article for more information. |
field |
String | A string representing the field name whose value is to be returned. This parameter can refer to any field in the data source, even if the current View does not contain a Grid |
#Returns
Type | Description |
---|---|
Object | An object that is the specified cell’s value. If the required value is not found in the data source (e. In Instant Feedback Mode, an invalid “Non-loaded Value” is immediately returned if the requested cell is not currently loaded. |
#Remarks
This method overrides the ColumnView.GetRowCellValue method to retrieve requested values for the auto filter row.
For more information, see ColumnView.GetRowCellValue.
Note
In Instant Feedback Mode, this Get
If you require this value right away (e.
private void gridView1_CustomDrawGroupRow(object sender, DevExpress.XtraGrid.Views.Base.RowObjectCustomDrawEventArgs e) {
GridView view = sender as GridView;
int index = view.GetDataRowHandleByGroupRowHandle(e.RowHandle);
var cellValue = view.GetRowCellValue(index, "Mode");
if (BaseEdit.IsNotLoadedValue(cellValue)) {
((GridGroupRowInfo)e.Info).GroupText = "Loading...";
}
else {
int mode = (int)cellValue;
((GridGroupRowInfo)e.Info).GroupText += "custom " + mode;
}
}
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 GetRowCellValue(Int32, String) 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.