GrapeCity SPREAD for WPF 2.0J
Formula プロパティ (GroupCell)

このグループセルの数式文字列を取得または設定します。
構文
'Declaration
 
Public Property Formula As String
public string Formula {get; set;}

プロパティ値

このグループセルの数式文字列。
解説

データ領域のセルは列名によってのみ参照できます。たとえば、グループフッタの最初のセルに数式 "SUM(Column1)" を設定すると、同じグループ内の Column1 のすべてのセルの合計がグループフッタの最初の列に表示されます。

参照できるのはデータ領域の列全体のみです。データ領域にある1つのセルまたはセル範囲を参照することはできません。

このプロパティを設定する前に、数式で参照する列に一意の名前を設定する必要があります。

セル参照数式は、同じグループヘッダまたはグループフッタ上のセルを参照する必要があります。

Formula プロパティを設定すると、AggregationType プロパティは自動的に AggregationType.Custom に設定されます。

次のサンプルはGcSpreadGridがデータをグループ化し、GroupInfo関数を使ってグループサマリーを表示します。
List<Customer> list = new List<Customer>();
list.Add(new Customer() { Name = "Nancy", Country = "Japan", City = "Tokyo" });
list.Add(new Customer() { Name = "Janet", Country = "Japan", City = "Sendai", });
list.Add(new Customer() { Name = "Rose", Country = "Japan", City = "Tokyo", });
list.Add(new Customer() { Name = "Buchanan", Country = "Japan", City = "Osaka", });
list.Add(new Customer() { Name = "Leverling", Country = "Japan", City = "Tokyo", });
list.Add(new Customer() { Name = "Gavin", Country = "China", City = "Beijing", });
list.Add(new Customer() { Name = "Victoria", Country = "China", City = "Xi'An", });
list.Add(new Customer() { Name = "Apple", Country = "China", City = "Beijing", });
list.Add(new Customer() { Name = "Tim", Country = "China", City = "Beijing", });
list.Add(new Customer() { Name = "John", Country = "China", City = "Xi'An", });

gcSpreadGrid1.ItemsSource = list;

Column column1 = gcSpreadGrid1.Columns["Country"];
GroupCell headerCell = column1.GroupHeader[0, 0];
headerCell.ColumnSpan = int.MaxValue;
headerCell.Background = Brushes.Azure;
headerCell.Formula = @"GroupInfo(""groupBy"") & "": "" & GROUPINFO(""groupText"")";

column1.GroupFooter.RowCount = 1;
column1.GroupFooter.Rows[0].Background = Brushes.LightBlue;
GroupCell footerCell1 = column1.GroupFooter[0, 0];
footerCell1.Value = "Count: ";
footerCell1.ColumnSpan = gcSpreadGrid1.ColumnCount - 1;
GroupCell footerCell2 = column1.GroupFooter[0, gcSpreadGrid1.ColumnCount - 1];
footerCell2.AggregationType = AggregationType.Count;

SpreadGroupDescription groupDescription = new SpreadGroupDescription();
groupDescription.ColumnName = "Country";
gcSpreadGrid1.GroupDescriptions.Add(groupDescription);
Dim list As New List(Of Customer)()
list.Add(New Customer() With { _
    .Name = "Nancy", _
    .Country = "Japan", _
    .City = "Tokyo" _
})
list.Add(New Customer() With { _
    .Name = "Janet", _
    .Country = "Japan", _
    .City = "Sendai" _
})
list.Add(New Customer() With { _
    .Name = "Rose", _
    .Country = "Japan", _
    .City = "Tokyo" _
})
list.Add(New Customer() With { _
    .Name = "Buchanan", _
    .Country = "Japan", _
    .City = "Osaka" _
})
list.Add(New Customer() With { _
    .Name = "Leverling", _
    .Country = "Japan", _
    .City = "Tokyo" _
})
list.Add(New Customer() With { _
    .Name = "Gavin", _
    .Country = "China", _
    .City = "Beijing" _
})
list.Add(New Customer() With { _
    .Name = "Victoria", _
    .Country = "China", _
    .City = "Xi'An" _
})
list.Add(New Customer() With { _
    .Name = "Apple", _
    .Country = "China", _
    .City = "Beijing" _
})
list.Add(New Customer() With { _
    .Name = "Tim", _
    .Country = "China", _
    .City = "Beijing" _
})
list.Add(New Customer() With { _
    .Name = "John", _
    .Country = "China", _
    .City = "Xi'An" _
})

gcSpreadGrid1.ItemsSource = list

Dim column1 As Column = gcSpreadGrid1.Columns("Country")
Dim headerCell As GroupCell = column1.GroupHeader(0, 0)
headerCell.ColumnSpan = Integer.MaxValue
headerCell.Background = Brushes.Azure
headerCell.Formula = "GroupInfo(""groupBy"") & "": "" & GROUPINFO(""groupText"")"

column1.GroupFooter.RowCount = 1
column1.GroupFooter.Rows(0).Background = Brushes.LightBlue
Dim footerCell1 As GroupCell = column1.GroupFooter(0, 0)
footerCell1.Value = "Count: "
footerCell1.ColumnSpan = gcSpreadGrid1.ColumnCount - 1
Dim footerCell2 As GroupCell = column1.GroupFooter(0, gcSpreadGrid1.ColumnCount - 1)
footerCell2.AggregationType = AggregationType.Count

Dim groupDescription As New SpreadGroupDescription()
groupDescription.ColumnName = "Country"
gcSpreadGrid1.GroupDescriptions.Add(groupDescription)
参照

GroupCell クラス
GroupCell メンバ

 

 


Copyright © 2012 GrapeCity inc. All rights reserved.