StringFormat は、集計結果の値を表示する時に使用するフォーマットを指定します。結果生じる値は SummaryResult の SummaryResult.DisplayText プロパティにより返されます。
文字列フォーマットは、集計値をフォーマットするために String.Format メソッドと使用されます。これによってフォーマット内に任意のテキストを指定できます。String.Format メソッドは、パラメーターとしての集計結果の値、集計計算式名(Sum、Average など)、集計定義のキー、およびソース フィールド名で呼び出されます。これは、{0}、{1}、{2} および {3} をそれぞれ使用して、指定するフォーマット内でこれらのいずれかの値を参照できることを意味します。
このプロパティのデフォルト値は "{1} = {0}" です。
Imports Infragistics.Windows Imports Infragistics.Windows.Editors Imports Infragistics.Windows.DataPresenter Private Sub Window1_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs) _dp.DataSource = _dataSource Dim fieldLayout As FieldLayout = _dp.FieldLayouts(0) Dim summary As SummaryDefinition = fieldLayout.SummaryDefinitions.Add(SummaryCalculator.Sum, "Price") ' StringFormat property's value is used to format the summary result using String's Format ' method. See .NET String.Format method for more information on available formatting options. summary.StringFormat = "Sum={0:C}" ' You can also specify a string format provider to use for the summary result. summary.StringFormatProvider = System.Globalization.CultureInfo.GetCultureInfo("fr-FR") ' Also note that SummaryStringFormats property of the Field can be used to control the format ' that gets assigned to summaries that the user selectes via the user interface (summary icon ' on the field label). This is in the format of "calculator_name1: format1, calculator_name2: format2". fieldLayout.Fields("Price").Settings.AllowSummaries = True fieldLayout.Fields("Price").SummaryStringFormats = _ "sum: TOTAL={0:c}, average: AVG={0:c}, count: COUNT={0}, minimum: MIN={0:c}, maximum: MAX={0:c}" End Sub
using Infragistics.Windows; using Infragistics.Windows.Editors; using Infragistics.Windows.DataPresenter; public void Window1_Loaded( object sender, RoutedEventArgs e ) { _dp.DataSource = _dataSource; FieldLayout fieldLayout = _dp.FieldLayouts[0]; SummaryDefinition summary = fieldLayout.SummaryDefinitions.Add( SummaryCalculator.Sum, "Price" ); // StringFormat property's value is used to format the summary result using String's Format // method. See .NET String.Format method for more information on available formatting options. summary.StringFormat = "Sum={0:C}"; // You can also specify a string format provider to use for the summary result. summary.StringFormatProvider = System.Globalization.CultureInfo.GetCultureInfo( "fr-FR" ); // Also note that SummaryStringFormats property of the Field can be used to control the format // that gets assigned to summaries that the user selectes via the user interface (summary icon // on the field label). This is in the format of "calculator_name1: format1, calculator_name2: format2". fieldLayout.Fields["Price"].Settings.AllowSummaries = true; fieldLayout.Fields["Price"].SummaryStringFormats = "sum: TOTAL={0:c}, average: AVG={0:c}, count: COUNT={0}, minimum: MIN={0:c}, maximum: MAX={0:c}"; }