Spread Windows Forms 7.0 Product Documentation
Setting up the Formula Text Box
See Also Support Options
Spread Windows Forms 7.0 Product Documentation > Developer's Guide > Customizing Interaction in Cells > Using the Additional Spread Controls > Setting up the Formula Text Box

Glossary Item Box

You can set up a floating formula bar that end users can use to add formulas. The formula bar is similar to the formula editor available to the developer and has the appearance of a text box. The formula bar provides a list of calculation functions. It also provides a visual method of selecting cell ranges for the formula.

Floating formula bar

Refer to the example below to see how to create the formula text box.

Setting up the Formula Text Box

To set up the formula bar at run time, use the FormulaTextBox class. You can also draw the formula text box on the form and assign it to Spread at design time. Select the formula text box icon in the Toolbox and drag it to the form. Select the formula text box verb and attach it to Spread.

The AllowUserFormulas property allows the user to type formulas in the cell.

If you set the AllowUserFormulas property to true for the control, then the formulas that are typed in a cell show up in the formula bar.

Using the Formula Text Box

To use the formula text box, type the equal sign (=) and then start typing the name of the formula. This brings up a list of functions that start with that letter. You can then type the left parenthesis and either select a block of cells by dragging the mouse over that range or type cell values by absolute or relative reference. The figure below shows the selection of a range of cells from A1 to B3.

Example of Conditional Format

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

Using Code

Create the formula editor and attach it to the control.

Example

This example code creates the floating formula bar.

C# Copy Code
FarPoint.Win.Spread.FormulaTextBox editor = new FarPoint.Win.Spread.FormulaTextBox();
editor.Location = new Point(0, 0);
editor.Size = new Size(80, 20);
this.Controls.Add(editor);
editor.Attach(fpSpread1);
// This line will disconnect the formula bar from the control
// editor.Detach();
VB Copy Code
Dim editor As New FarPoint.Win.Spread.FormulaTextBox
editor.Location = New Point(0, 0)
editor.Size = New Size(80, 20)
Controls.Add(editor)
editor.Attach(FpSpread1)
‘ This line will disconnect the formula bar from the control
‘ editor.Detach()

See Also

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