Spread Windows Forms 8.0 Product Documentation > Developer's Guide > Customizing Interaction in Cells > Using the Additional Spread Controls > Setting up the Formula Provider |
You can add a formula provider control to the form. The provider control allows you to add values from other controls using formulas and put the result in a control on the form. Custom formula functions can be used (AddCustomFunctionInfo method) as well as custom names (AddQueryValueName method). The provider control can be added to the Toolbox. Find the formula provider control in the list of .NET controls that can be added to the Toolbox and select it.
Double-click the formula provider control after selecting it from the Toolbox.
Two design properties will be added to each control on the form. The Formula on Formula Provider property is the property for setting a formula. The Formula Trigger Event on Formula Provider property allows you to determine which event will cause the formula to update.
The following basic example shows how to use the formula provider at design time. This example uses two text box controls and the formula provider. The second text box displays the value from the first text box. The formula for the second text box (Formula on Formula Provider property) has been set to be equal to the first text box. The trigger event (FormulaTriggerEvent) has been set to the TextChanged event.
For more information on formulas, refer to Managing Formulas in Cells and the Formula Reference.
Add the formula provider and two text box controls to the form and set the SetFormula and SetFormulaTriggerEvent methods for the formula provider.
This example gets the typed data from text box 1 and puts it in text box 2.
C# |
Copy Code
|
---|---|
FormulaProvider1.SetFormula(TextBox2, "=TextBox1"); FormulaProvider1.SetFormulaTriggerEvent(TextBox1, "TextChanged"); |
VB |
Copy Code
|
---|---|
FormulaProvider1.SetFormula(TextBox2, "=TextBox1") FormulaProvider1.SetFormulaTriggerEvent(TextBox1, "TextChanged") |