Working with CalcQuick Demo

This sample is a combination of six other samples that share common tasks. The sample guides you through these associated tasks using CalcQuick objects.

The samples can be divided into ones that require manual retrieval of computed values and automatic updating of calculations as trigger values change. These two sub-divisions are explained in the following sections. The last section deals with a simple way to set up auto-calculations when using control-derived objects.

Features:

Manual Calculations

Manual calculations provide the simplest way to use a CalcQuick object, but the computed values have to be manually retrieved when required.

 		
    			//calculator is a CalcQuick object...
    			//calculator = new CalcQuick();

    			//Set the values of A, B, C, D
    			calculator["A"] = this.textBox1.Text;
    			calculator["B"] = this.textBox2.Text;
    			calculator["C"] = this.textBox3.Text;
    			calculator["D"] = this.textBox4.Text;

    			//mark as dirty so any formulas will be recomputed
    			calculator.SetDirty();

    			//Get the values
    			this.textBox1.Text = calculator["A"].ToString();
    			this.textBox2.Text = calculator["B"].ToString();
    			this.textBox3.Text = calculator["C"].ToString();
    			this.textBox4.Text = calculator["D"].ToString();

The following image was captured before pressing the Calculate button. It displays values as typed into the text boxes.

Before Code Execution
Before Code Execution


The following image was captured after pressing the Calculate button. It displays values computed from formulae in the text boxes.

After Code Execution
After Code Execution


The 'Reset Keys' button help us to clear all the registered keys with the CalcQuickBase object.

AutoCalculations

AutoCalculations are events that need to be handled to receive calculated formula values and notify CalcQuick of a value change.

Controls as Keys

CalcQuick has a method that allows setting up all events necessary to support automatic calculations in one method call, provided the objects holding values or formulas are control-derived classes.    

This feature is illustrated in the following image.

Automatic Total Adjustment On Adding Information
Automatic Total Adjustment on Adding Information