开发者

How to get the cell value from an unbound column directly after updating it?

I have the following situation.

I build a grid from a collection of objects. I than add two unbound columns. The first unbound column has a RepositoryItemSpinEdit Editor and contains integers. the second unbound column only contains integers.

i am trying to update the second column immediatly after changing the first one. But the second column only gets updated after the first one has lost focus. It than shows the updated value in Position while Profit is calculated with the former value in Position. Any idea how to trick the system to do what i want?

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.gridV开发者_运维知识库iew.GetRow(rowIndex) as Curve;
    this.gridControl.SetGridViewCurve(curve.ID, "Profit", curve.Price * curve.Position);
}


All i had to do is call

this.gridView.PostEditor()

in the method that is called when the event is raised.

More Information can be found here and here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜