![]() | |
Using Setters to Update Computed Columns |
The example shows how a computed column can be made writable by redirecting input.
Use BCF Editor to add PointFunction and PointSetter to a column.
The example is simplified and will only work if X and Y are on the same row like the computed point.
public class PointFunction : BcfFunctionBase<Point> { [BcfMandatory] public int X { get; set; } [BcfMandatory] public int Y { get; set; } public override Point Compute() { return new Point(X, Y); } }
public class PointSetter : BcfColumnValueSetter { public override void SetValue(BcfCell cell, object value) { var point = (Point) value; var xColumn = cell.Column.Function.Parameters.First(p => p.Name == "X").SourceColumn; var yColumn = cell.Column.Function.Parameters.First(p => p.Name == "Y").SourceColumn; cell.Row[xColumn].Value = point.X; cell.Row[yColumn].Value = point.Y; } }