Spread Windows Forms 6.0 Product Documentation
Setting up the Formula Provider
Support Options
Spread Windows Forms 6.0 Product Documentation > Developer's Guide > Customizing Interaction in Cells > Using the Additional Spread Controls > Setting up the Formula Provider

Glossary Item Box

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.

Floating formula bar

Setting up the Formula Provider Control

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.

Using the Formula Provider

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.

Example of Conditional Format

A formula provider example that demonstrates custom formula functions and custom names is available in the samples folder.

See Also

For more information on formulas, refer to Managing Formulas in Cells and the Formula Reference.

For more information on allowing the user to enter formulas, refer to Allowing the User to Enter Formulas.

Return to Using the Additional Spread Controls.

Using Code

Add the formula provider and two text box controls to the form and set the SetFormula and SetFormulaTriggerEvent methods.

Example

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")
 

© 2002-2012 ComponentOne, a division of GrapeCity. All Rights Reserved.