# Add a Formula Bar

This topic explains how to add a formula bar, which allows you to work with various formulas and functions in the Spread for WPF.

## Content

You can enhance the GcSpreadSheet component by adding a formula bar, enabling seamless interaction with various formulas and functions by associating it with a worksheet. To integrate and use the GcFormulaBar, follow the steps outlined in the [Quick Start](/spreadnet/docs/latest/online-wpf/quickstart) to effectively connect the two components.
The image below demonstrates how the GcFormulaBar integrates with the GcSpreadSheet component. The formula bar shows the formula applied to the cell range B2:B6, providing a clear visual representation of the formula in action.
![](https://cdn.mescius.io/document-site-files/images/0f63724f-fddf-4351-8c24-0b4338c0fda9/images/add-formulabar.png)
Refer to the following example code to add a formula bar with the GcSpreadSheet component and use the SUM formula to calculate the total sales.

```xml
<Grid>
    <gss:GcFormulaBar HorizontalAlignment="Left" Margin="10,19,0,0" VerticalAlignment="Top" ShowEditingButtons="True" Expandable="True" AssociatedSpread="{x:Reference Name=spreadSheet1}"/>
    <gss:GcSpreadSheet Name="spreadSheet1" HorizontalAlignment="Center" Margin="10,50,0,0" VerticalAlignment="top"/>
</Grid>
```

**C#**

```csharp
// Add SUM formula to get the total sales.
spreadSheet1.Workbook.ActiveSheet.Cells["B8"].Text = "Total Sales:";
spreadSheet1.Workbook.ActiveSheet.Cells["C8"].Formula = "SUM(B2:B6)";
spreadSheet1.Workbook.ActiveSheet.Cells["C8"].Activate();
```

**VB**

```auto
' Add SUM formula to get the total sales.
spreadSheet1.Workbook.ActiveSheet.Cells("B8").Text = "Total Sales:"
spreadSheet1.Workbook.ActiveSheet.Cells("C8").Formula = "SUM(B2:B6)"
spreadSheet1.Workbook.ActiveSheet.Cells("C8").Activate()
```