Syncfusion.Calculate.Base
Members  Example 


Syncfusion.Calculate Namespace : CalcQuickBase Class

CalcQuickBase Class

A class that allows you to quickly add calculation support for controls on a form, or usercontrol.
Syntax
'Declaration
 
<DefaultMemberAttribute("Item")>
Public Class CalcQuickBase 
   Implements ICalcData, ISheetData 
'Usage
 
Dim instance As CalcQuickBase
[DefaultMember("Item")]
public class CalcQuickBase : ICalcData, ISheetData  
Remarks
To use CalcQuick, you instantiate an instance of the class. Then just by indexing the class object with string names to identify a formula object, you can have calculation support in your form. Alternatively, you can add a collection of Control-derived objects and the CalcQuick object will bind the Control.Text property allowing you to use the Control/Name property to reference other controls in a formula.
Example
Here is code that uses three TextBoxes, the first showing a value for an angle in degrees, and the other two displaying the sine and cosine of this angle. In this code, the calculations are done on the click of a button: Here is code that uses the same three TextBoxes as above, but this time the code is set up to automatically compute things as you change the value in the Angle TextBox. There is no longer a need for a button handler to trigger setting / getting values.
CalcQuick calculator = null;
   private void AngleForm_Load(object sender, System.EventArgs e)
   {
       //TextBox Angle = new TextBox();
       this.Angle.Name = "Angle";
       this.Angle.Text = "30";
       //cosTB = new TextBox();
       this.cosTB.Name = "cosTB";
       this.cosTB.Text = "= cos([Angle] * pi() / 180) ";
       //sinTB = new TextBox();
       this.sinTB.Name = "sinTB";
       this.sinTB.Text = "= sin([Angle] * pi() / 180) ";
       // Instantiate the CalcQuick object:
       this.calculator = new CalcQuick();
   }
   // Perform a manual calculation:
   private void ComputeButton_Click(object sender, System.EventArgs e)
   {
       // Let the calculator know the values/formulas
       // by using an indexer on the calculator object.
       // Here we are using the TextBox.Name as the indexer key
       // provided to the calculator object. This is not required.
       // The only restriction for the indexer key values is that they
       // be unique nonempty strings:
       this.calculator["Angle"] = this.Angle.Text;
       this.calculator["cosTB"] = this.cosTB.Text;
       this.calculator["sinTB"] = this.sinTB.Text;
       // Mark the calculator dirty:
       this.calculator.SetDirty();
       // Now as the values are retrieved from the calculator, they
       // will be the newly calculated values:
       this.cosTB.Text = this.calculator["cosTB"];
       this.sinTB.Text = this.calculator["sinTB"];
   }
Dim calculator As CalcQuick = Nothing
   Private Sub AngleForm_Load(sender As Object, e As System.EventArgs)
       'TextBox Angle = new TextBox();
       Me.Angle.Name = "Angle"
       Me.Angle.Text = "30"
       'cosTB = new TextBox();
       Me.cosTB.Name = "cosTB"
       Me.cosTB.Text = "= cos([Angle] * pi() / 180) "
            
       'sinTB = new TextBox();
       Me.sinTB.Name = "sinTB"
       Me.sinTB.Text = "= sin([Angle] * pi() / 180) "
            
       'Instantiate the CalcQuick object:
       Me.calculator = New CalcQuick()
       End Sub 'AngleForm_Load
            
   'Perform a manual calculation:
   Private Sub ComputeButton_Click(sender As Object, e As System.EventArgs)
       'Let the calculator know the values/formulas
       'by using an indexer on the calculator object.
       'Here we are using the TextBox.Name as the indexer key
       'provided to the calculator object. This is not required.
       'The only restriction for the indexer key values is that they
       'be unique nonempty strings:
       Me.calculator("Angle") = Me.Angle.Text
       Me.calculator("cosTB") = Me.cosTB.Text
       Me.calculator("sinTB") = Me.sinTB.Text
            
       'Mark the calculator dirty:
       Me.calculator.SetDirty()
            
       'Now as the values are retrieved from the calculator, they
       'will be the newly calculated values:
       Me.cosTB.Text = Me.calculator("cosTB")
       Me.sinTB.Text = Me.calculator("sinTB")
   End Sub 'ComputeButton_Click
CalcQuick calculator = null;
            
   private void AngleForm_Load(object sender, System.EventArgs e)
   {
       //TextBox Angle = new TextBox();
       this.Angle.Name = "Angle";
       this.Angle.Text = "30";
            
       //cosTB = new TextBox();
       this.cosTB.Name = "cosTB";
       this.cosTB.Text = "= cos([Angle] * pi() / 180) ";
            
       //sinTB = new TextBox();
       this.sinTB.Name = "sinTB";
       this.sinTB.Text = "= sin([Angle] * pi() / 180) ";
            
       // Instantiate the CalcQuick object:
       this.calculator = new CalcQuick();
   }
            
   // Perform a manual calculation:
   private void ComputeButton_Click(object sender, System.EventArgs e)
   {
       // Let the calculator know the values/formulas
       // by using an indexer on the calculator object.
       // Here we are using the TextBox.Name as the indexer key
       // provided to the calculator object. This is not required.
       // The only restriction for the indexer key values is that they
       // be unique nonempty strings:
       this.calculator["Angle"] = this.Angle.Text;
       this.calculator["cosTB"] = this.cosTB.Text;
       this.calculator["sinTB"] = this.sinTB.Text;
            
       // Mark the calculator dirty:
       this.calculator.SetDirty();
            
       // Now as the values are retrieved from the calculator, they
       // will be the newly calculated values:
       this.cosTB.Text = this.calculator["cosTB"];
       this.sinTB.Text = this.calculator["sinTB"];
   }
Dim calculator As CalcQuick = Nothing
            
   Private Sub AngleForm_Load(sender As Object, e As System.EventArgs)
       'TextBox Angle = new TextBox();
       Me.Angle.Name = "Angle"
       Me.Angle.Text = "30"
            
       'cosTB = new TextBox();
       Me.cosTB.Name = "cosTB"
       Me.cosTB.Text = "= cos([Angle] * pi() / 180) "
            
       'sinTB = new TextBox();
       Me.sinTB.Name = "sinTB"
       Me.sinTB.Text = "= sin([Angle] * pi() / 180) "
            
       'Instantiate the CalcQuick object:
       Me.calculator = New CalcQuick()
       End Sub 'AngleForm_Load
            
   'Perform a manual calculation:
   Private Sub ComputeButton_Click(sender As Object, e As System.EventArgs)
       'Let the calculator know the values/formulas
       'by using an indexer on the calculator object.
       'Here we are using the TextBox.Name as the indexer key
       'provided to the calculator object. This is not required.
       'The only restriction for the indexer key values is that they
       'be unique nonempty strings:
       Me.calculator("Angle") = Me.Angle.Text
       Me.calculator("cosTB") = Me.cosTB.Text
       Me.calculator("sinTB") = Me.sinTB.Text
            
       'Mark the calculator dirty:
       Me.calculator.SetDirty()
            
       'Now as the values are retrieved from the calculator, they
       'will be the newly calculated values:
       Me.cosTB.Text = Me.calculator("cosTB")
       Me.sinTB.Text = Me.calculator("sinTB")
   End Sub 'ComputeButton_Click
Inheritance Hierarchy

System.Object
   Syncfusion.Calculate.CalcQuickBase
      Syncfusion.Calculate.CalcQuick

AssemblyVersion

Syncfusion.Calculate.Base: 17.4460.0.39

See Also