ドロップダウン電卓の機能を使用するには、ドロップダウン電卓を表す GcDropDownCalculator コントロールのスタイルを設定します。
ドロップダウン電卓にスタイルを設定するには、次の2つの方法があります。
それぞれの方法について説明します。
GcDropDownCalculator コントロールのスタイルを定義し x:Key 属性でキーを設定します。そして、数値型セルの DropDownCalculatorStyle プロパティでキーを指定してスタイルを参照します。
次のサンプルコードは、ドロップダウン電卓の履歴表示を無効にします。
| xaml |
コードのコピー |
|---|---|
<sg:GcSpreadGrid Name="gcSpreadGrid1"> <sg:GcSpreadGrid.Resources> <Style TargetType="sg:GcDropDownCalculator" x:Key="MyCalculatorStyle"> <Setter Property="IsShowHistory" Value="False"/> </Style> </sg:GcSpreadGrid.Resources> <sg:GcSpreadGrid.Columns> <sg:Column> <sg:Column.CellType> <sg:NumberCellType AllowDropDownOpen="True" DropDownButtonVisibility="AlwaysShow" DropDownCalculatorStyle="{StaticResource MyCalculatorStyle}"/> </sg:Column.CellType> </sg:Column> </sg:GcSpreadGrid.Columns> </sg:GcSpreadGrid> | |
次のサンプルコードは、コード ビハインドからスタイルを参照する例です。
| C# |
コードのコピー |
|---|---|
NumberCellType num = new NumberCellType(); num.DropDownButtonVisibility = CellButtonVisibility.AlwaysShow; num.DropDownCalculatorStyle = gcSpreadGrid1.FindResource("MyCalculatorStyle") as Style; gcSpreadGrid1.Columns[0].CellType = num; | |
| Visual Basic |
コードのコピー |
|---|---|
Dim num As New NumberCellType() num.DropDownButtonVisibility = CellButtonVisibility.AlwaysShow num.DropDownCalculatorStyle = TryCast(gcSpreadGrid1.FindResource("MyCalculatorStyle"), Style) gcSpreadGrid1.Columns(0).CellType = num | |
DropDownCalculatorEditElement のスタイルを x:Key 属性なしで定義します。この場合、スタイルを定義したリソースの対象範囲内のすべての数値型セルにスタイルが暗黙的に適用されます。
次のサンプルコードは、ドロップダウン電卓の履歴表示を無効にします。この設定は、GcSpreadGrid コントロール内のすべての数値型セルに対して有効です。
| xaml |
コードのコピー |
|---|---|
<sg:GcSpreadGrid Name="gcSpreadGrid1"> <sg:GcSpreadGrid.Resources> <Style TargetType="sg:DropDownCalculatorEditElement"> <Setter Property="IsShowHistory" Value="False"/> </Style> </sg:GcSpreadGrid.Resources> <sg:GcSpreadGrid.Columns> <sg:Column> <sg:Column.CellType> <sg:NumberCellType AllowDropDownOpen="True" DropDownButtonVisibility="AlwaysShow"/> </sg:Column.CellType> </sg:Column> </sg:GcSpreadGrid.Columns> </sg:GcSpreadGrid> | |