我有以下情况。
我从一组对象构建一个网格。我比添加两个未绑定的列。 第一个未绑定列具有RepositoryItemSpinEdit编辑器并包含整数。第二个未绑定列只包含整数。
我正在尝试在更改第一列后立即更新第二列。但是第二列只有在第一列失去焦点后才会更新。它显示位置中的更新值,而利用位置中的前一个值计算利润。 知道如何欺骗系统做我想做的事吗?
var spinEditor = new RepositoryItemSpinEdit
{
MaxValue = 999999,
MinValue = -999999,
IsFloatValue = false,
};
spinEditor.EditValueChanged += this.CalculateProfit;
this.gridView.GridControl.RepositoryItems.Add(spinEditor);
this.gridView.Columns.AddField("Position");
this.gridView.Columns["Position"].Caption = "Position";
this.gridView.Columns["Position"].VisibleIndex = this.grid.VisibleColumns.Count;
this.gridView.Columns["Position"].ColumnEdit = spinEditor;
this.gridView.Columns["Position"].UnboundType = UnboundColumnType.Integer;
this.gridView.Columns["Position"].DisplayFormat.FormatType = FormatType.Numeric;
this.gridView.Columns.AddField("Profit");
this.gridView.Columns["Profit"].Caption = "PnL";
this.gridView.Columns["Profit"].VisibleIndex = this.gridView.VisibleColumns.Count;
this.gridView.Columns["Profit"].UnboundType = UnboundColumnType.Decimal;
this.gridView.Columns["Profit"].DisplayFormat.FormatType = FormatType.Numeric;
private void CalculateProfit(object sender, EventArgs eventArgs)
{
int rowIndex = this.gridView.FocusedRowHandle;
var curve = this.gridView.GetRow(rowIndex) as Curve;
this.gridControl.SetGridViewCurve(curve.ID, "Profit", curve.Price * curve.Position);
}