[This is preliminary documentation and is subject to change.]
Returns The delta between the value of expression before the EnterRow event, and the current value of expression
Namespace:
Firefly.BoxAssembly: Firefly.Box (in Firefly.Box.dll) Version: 3.4.23.6473 (3.4.23.6473)
Syntax
C# |
---|
public Number DeltaOf( Func<Number> expression ) |
Visual Basic (Declaration) |
---|
Public Function DeltaOf ( _ expression As Func(Of Number) _ ) As Number |
Visual C++ |
---|
public: Number^ DeltaOf( Func<Number^>^ expression ) |
Parameters
- expression
- Type: System..::.Func<(Of <(Number>)>)
Return Value
The method returns The delta between the value of expression before the EnterRow event, and the current value of expression
Remarks
Useful for maintaining a grand total in a form
Examples
How to use DeltaOf to maintain a grand total
This example is based on test data. The code for the entities included in this test data can be found in the documentation of Entity
This example uses automatic tools to generate parts of the user interface. Those tools can be found in the example of the documentation of Form
CopyC#
This example is based on test data. The code for the entities included in this test data can be found in the documentation of Entity
This example uses automatic tools to generate parts of the user interface. Those tools can be found in the example of the documentation of Form

using Firefly.Box; using Firefly.Box.Data; using Firefly.Box.UI; namespace TestFirefly.Box.Documentation { public class JobsTotal { public void ShowJobs() { var jobs = new Pubs.Jobs(); jobs.InitializeWithTestData(); var totalMinLevel = new NumberColumn(); var countJobs = new NumberColumn(); //Calculate the total before running the task var bp = new BusinessProcess { From = jobs }; bp.ForEachRow(() => { totalMinLevel.Value += jobs.MinLevel; countJobs.Value++; }); //Create the total textbox var totalTextBox = new TextBox { Data = totalMinLevel, AllowFocus = false }; //Position the textbox below the grid totalTextBox.ResizeToFit(10); //Create a label var totalLabel = new Label { Text = "Total Min Level" }; totalLabel.ResizeToFitContent(); var countTextBox = new TextBox { Data = countJobs, AllowFocus = false }; countTextBox.ResizeToFit(6); var countLabel = new Label { Text = "Number of jobs" }; countLabel.ResizeToFitContent(); //Create the UIController var uic = new UIController { From = jobs, View = UITools.GenerateFormWithGridFor( "DeltaOf demo", "Change the value of Min Level, and leave the row to see the affect on the totals.\n" + "Try also deleting rows (using F3) and creating new ones." , jobs.Id , jobs.Description , jobs.MinLevel) }; UITools.AddControlsToForm(uic.View, countLabel, countTextBox, totalLabel, totalTextBox); var insertB = new Button { Text = "Insert New Row", Width = 150 }; insertB.Click += (sender, e) => e.Raise(Command.InsertRow); var deleteB = new Button { Text = "Delete Row", Width = 100 }; deleteB.Click += (sender, e) => e.Raise(Command.DeleteRow); UITools.AddControlsToForm(uic.View, insertB, deleteB); //Add all the jobs columns to the Columns Collection uic.AddAllColumns(); //Add the total columns to the columns collection uic.Columns.Add(totalMinLevel, countJobs); uic.SavingRow += ( b) => //When the row is left, update the total with the delta in the MinLevel { totalMinLevel.Value += uic.DeltaOf(() => jobs.MinLevel); countJobs.Value += uic.DeltaOf(() => 1); }; uic.Run(); } } }
Examples
How to use DeltaOf in a business process
This example is in the form of Unit Tests. It references the NUnit framework. This framework can be downloaded from www.NUnit.org. For more information about unit testing visit: www.NUnit.org.
This example is based on test data. The code for the entities included in this test data can be found in the documentation of Entity
CopyC#
This example is in the form of Unit Tests. It references the NUnit framework. This framework can be downloaded from www.NUnit.org. For more information about unit testing visit: www.NUnit.org.
This example is based on test data. The code for the entities included in this test data can be found in the documentation of Entity

using System; using System.Collections.Generic; using System.Text; using NUnit.Framework; using Firefly.Box; using Firefly.Box.Testing; namespace TestFirefly.Box.Documentation { [TestFixture] public class DemoDeltaOf { [Test] public void BusinessProcess() { var jobs = new Pubs.Jobs(); jobs.InitializeWithTestData(); var bp = new BusinessProcess() { From = jobs }; bp.ForFirstRow(() => { jobs.MinLevel.ShouldBe(10); jobs.MinLevel.Value = 25; bp.DeltaOf(() => jobs.MinLevel).ShouldBe(15); }); } } }