Version

StringFormat Property (SummaryDefinition)

Specifies the format to use to when displaying the summary result's value.
Syntax
'Declaration
 
Public Property StringFormat As String
public string StringFormat {get; set;}
Remarks

StringFormat specifies the format to use when displaying the summary result's value. The resulting value is returned by the SummaryResult's SummaryResult.DisplayText property.

String format is used with the String.Format method to format the summary value. This lets you specify any arbitrary text inside the format. String.Format method is called with summary result's value, sumamry calculator name (Sum, Average etc...), summary definition's key, and the source field name as parameters. This means that you can refer to any of these values inside the format you specify using {0}, {1}, {2} and {3} respectively.

The default value of this property is "{1} = {0}".

Example
The following code demonstrates the usage of SummaryDefinition's StringFormat and StringFormatProvider properties and also the Field's SummaryStringFormats property.

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}";
		}
        <igDP:XamDataGrid x:Name="_dp" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >

            
<igDP:XamDataGrid.FieldLayouts>
                
<igDP:FieldLayout IsDefault="true" >
                    
<igDP:FieldLayout.SummaryDefinitions>
                        
<!--
                         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.
                        
-->
                        
<igDP:SummaryDefinition 
                                
SourceFieldName="Price" 
                                
Calculator="Sum" 
                                
StringFormat="{}Sum={0:C}"
                            
/>
                    
</igDP:FieldLayout.SummaryDefinitions>

                    
<igDP:FieldLayout.Fields>
                        
<!--
                         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".
                        
-->
                        
<igDP:Field
                                
Name="Price"
                                
SummaryStringFormats="{}sum: TOTAL={0:c}, average: AVG={0:c}, count: COUNT={0}, minimum: MIN={0:c}, maximum: MAX={0:c}"
                            
>
                            
<igDP:Field.Settings>
                                
<igDP:FieldSettings AllowSummaries="true" />
                            
</igDP:Field.Settings>
                        
</igDP:Field>
                    
</igDP:FieldLayout.Fields>
                
</igDP:FieldLayout>
            
</igDP:XamDataGrid.FieldLayouts>

        
</igDP:XamDataGrid>
Requirements

Target Platforms: Windows 10, Windows 8.1, Windows 8, Windows 7, Windows Server 2012, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also