시나리오 : 그리드 레코드를 반복하고 “Price”열 값을 10% 줄이는 예시코드
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(); }
}
시나리오 : TextEdit의 value값으로 GridControl의 필터를 적용할때
private void textEditShortcut_TextChanged(object sender, EventArgs e)
{
SetAutoFilterRow(sender, gridColumnDriverShortcut);
}
private void textEditCallerLineNumber_TextChanged(object sender, EventArgs e)
{
SetAutoFilterRow(sender, gridColumnCallerLineNumber);
}
private void textEditSeq_TextChanged(object sender, EventArgs e)
{
SetAutoFilterRow(sender, gridColumnSeq);
}
// .
// .
// .
private void SetAutoFilterRow(object sender, GridColumn gridColumn)
{
if (sender is TextEdit textEdit)
{
gridViewMain.SetRowCellValue(GridControl.AutoFilterRowHandle, gridColumn, textEdit.EditValue);
}
}