[]
        
(Showing Draft Content)

Drop-Down Calculator

Number cells provide a drop-down calculator for entering and calculating numeric values. Users can open the calculator window via the drop-down button or keyboard shortcuts.

image

Display the Drop-Down Calculator

  • Click the drop-down button: Click the drop-down button on the right side of the cell directly.

  • Keyboard shortcut: Press the [F4] key or [Alt] + Down Arrow key.

To enable the display of the drop-down calculator, set the AllowDropDownOpen property to True. The display mode of the drop-down button can be configured using the DropDownButtonVisibility property.

Display History

Whether to display the history of the current calculation can be set using the IsShowHistory property.

When history is enabled, for example, if you enter 12+34-56, the history 12+34- will appear above the output area, and the current input 56 will be shown below.

image

Drop-Down Calculator Style Settings

The style of the drop-down calculator uses the WPF Style mechanism and is defined via XAML. There are two main configuration methods:

Referencing Style by Key

Define a style for the GcDropDownCalculator control and name it using the x:Key property. Then specify the corresponding style in the numeric cell's DropDownCalculatorStyle property.

<gss:GcSpreadSheet x:Name="GcSpreadSheet" HorizontalAlignment="Left" VerticalAlignment="Top">
    <gss:GcSpreadSheet.Resources>
        <Style TargetType="gss:GcDropDownCalculator" x:Key="MyCalculatorStyle">
            <Setter Property="IsShowHistory" Value="False"/>
        </Style>
    </gss:GcSpreadSheet.Resources>
    <gss:GcSpreadSheet.Sheets>
        <gss:SheetInfo RowCount="10" ColumnCount="5">
            <gss:SheetInfo.Columns>
                <gss:ColumnInfo Width="200">
                    <gss:ColumnInfo.CellType>
                        <gss_CellType:NumberCellType AllowDropDownOpen="True" DropDownButtonVisibility="AlwaysShow"
                                DropDownCalculatorStyle="{StaticResource MyCalculatorStyle}"/>
                    </gss:ColumnInfo.CellType>
                </gss:ColumnInfo>
            </gss:SheetInfo.Columns>
        </gss:SheetInfo>
    </gss:GcSpreadSheet.Sheets>
</gss:GcSpreadSheet>

Note: When using cell types in XAML, you need to declare the following namespace: xmlns:gss_CellType="clr-namespace:GrapeCity.Wpf.SpreadSheet.CellType;assembly=GrapeCity.Wpf.SpreadSheet.CellType"

NumberCellType num = new NumberCellType();
num.DropDownButtonVisibility = CellButtonVisibility.AlwaysShow;
num.DropDownCalculatorStyle = GcSpreadSheet.FindResource("MyCalculatorStyle") as Style;
spreadSheet1.Workbook.Worksheets[0].Columns[0].CellType = num;
spreadSheet1.Workbook.Worksheets[0].Columns[0].ColumnWidth = 300;
Dim num As NumberCellType = New NumberCellType()
num.DropDownButtonVisibility = CellButtonVisibility.AlwaysShow
num.DropDownCalculatorStyle = TryCast(GcSpreadSheet.FindResource("MyCalculatorStyle"), Style)
spreadSheet1.Workbook.Worksheets[0].Columns(0).CellType = num
spreadSheet1.Workbook.Worksheets[0].Columns(0).ColumnWidth = 300

Implicit Style Application

When defining a style for GcDropDownCalculator, do not set the x:Key property. In this case, the style will be automatically applied to all numeric cells within the scope of the resource.

<gss:GcSpreadSheet x:Name="GcSpreadSheet" HorizontalAlignment="Left" VerticalAlignment="Top">
    <gss:GcSpreadSheet.Resources>
        <Style TargetType="gss:GcDropDownCalculator">
            <Setter Property="IsShowHistory" Value="False"/>
        </Style>
    </gss:GcSpreadSheet.Resources>
    <gss:GcSpreadSheet.Sheets>
        <gss:SheetInfo RowCount="10" ColumnCount="5">
            <gss:SheetInfo.Columns>
                <gss:ColumnInfo Width="200">
                    <gss:ColumnInfo.CellType>
                        <gss_CellType:NumberCellType AllowDropDownOpen="True" DropDownButtonVisibility="AlwaysShow"/>
                    </gss:ColumnInfo.CellType>
                </gss:ColumnInfo>
            </gss:SheetInfo.Columns>
        </gss:SheetInfo>
    </gss:GcSpreadSheet.Sheets>
</gss:GcSpreadSheet>

Note: When using cell types in XAML, you need to declare the following namespace: xmlns:gss_CellType="clr-namespace:GrapeCity.Wpf.SpreadSheet.CellType;assembly=GrapeCity.Wpf.SpreadSheet.CellType"