'Declaration Public Property AllowSummaries As Nullable(Of Boolean)
public Nullable<bool> AllowSummaries {get; set;}
AllowSummaries enables the summary calculation selection UI. A summary icon will be displayed inside the field label. Note that depending on the theme being used, the icon may get displayed when hovering the mouse over the field label. When the icon is clicked, it will display the UI for selecting the type of summary calculation to perform on the field. The calculated summary result will be displayed in a summary record. The summary result by default is displayed in the summary record at the end of the record collection however you can control if and where the summary result is displayed by setting the FieldSettings' SummaryDisplayArea property.
Also SummaryUIType property provides you with options for controlling whether the summary selection UI allows the user to select only one summary per field as well as whether summary selection UI is enabled only on numeric fields (see SingleSelectForNumericsOnly and MultiSelectForNumericsOnly options of the SummaryUIType enumeration).
To specify summary calculations to perform in code, use the FieldLayout's property. Also as the user selects summaries, this collection will be modified to reflect user selected summaries.
Private Sub Window1_Loaded(ByVal sender As Object, ByVal e As RoutedEventArgs) ' Set the data source. _dp.DataSource = _dataSource ' AllowSummaries enables the UI for the user to be able to select/unselect ' summaries for fields. SummaryUIType specifies whether the user is allowed to ' select single or multiple summaries pereach field. It also has options for ' enabling summary selection UI for numeric fields only or for all fields. ' _dp.FieldSettings.AllowSummaries = True _dp.FieldSettings.SummaryUIType = SummaryUIType.MultiSelect ' To add a summary, use the SummaryDefinitions property of the FieldLayout. ' Each SummaryDefinition object represents a summary calculation to perform ' on a field's data. SourceFieldName specifies the field whose data will be ' summarized. Key is optional and it simply associates an identifier to the ' summary. This identifier can be used later to access the summary via ' indexers of SummaryDefinitionCollection and SummaryResultCollection. ' Calculator specifies the type of calculation to perform on the field data. ' There are five built in calculators of Average, Sum, Minimum, Maximum and ' Count. However you can easily add custom calculators by deriving from ' SummaryCalculator base class and registering the new calculator using the ' SummaryCalculator's Register static method. ' Dim summaryDef1 As SummaryDefinition = _dp.FieldLayouts(0).SummaryDefinitions.Add( _ "PriceAverage", SummaryCalculator.Average, "Price") ' StringFormat specifies the format that will be used to format the summary ' result. ' summaryDef1.StringFormat = "Avg={0:C}" ' Add a second summary. Dim summaryDef2 As SummaryDefinition = _dp.FieldLayouts(0).SummaryDefinitions.Add( _ "PriceTotal", SummaryCalculator.Sum, "Price") summaryDef2.StringFormat = "Total={0:C}" End Sub
public void Window1_Loaded( object sender, RoutedEventArgs e ) { // Set the data source. _dp.DataSource = _dataSource; // AllowSummaries enables the UI for the user to be able to select/unselect // summaries for fields. SummaryUIType specifies whether the user is allowed to // select single or multiple summaries pereach field. It also has options for // enabling summary selection UI for numeric fields only or for all fields. // _dp.FieldSettings.AllowSummaries = true; _dp.FieldSettings.SummaryUIType = SummaryUIType.MultiSelect; // To add a summary, use the SummaryDefinitions property of the FieldLayout. // Each SummaryDefinition object represents a summary calculation to perform // on a field's data. SourceFieldName specifies the field whose data will be // summarized. Key is optional and it simply associates an identifier to the // summary. This identifier can be used later to access the summary via // indexers of SummaryDefinitionCollection and SummaryResultCollection. // Calculator specifies the type of calculation to perform on the field data. // There are five built in calculators of Average, Sum, Minimum, Maximum and // Count. However you can easily add custom calculators by deriving from // SummaryCalculator base class and registering the new calculator using the // SummaryCalculator's Register static method. // SummaryDefinition summaryDef1 = _dp.FieldLayouts[0].SummaryDefinitions.Add( "PriceAverage", SummaryCalculator.Average, "Price" ); // StringFormat specifies the format that will be used to format the summary // result. // summaryDef1.StringFormat = "Avg={0:C}"; // Add a second summary. SummaryDefinition summaryDef2 = _dp.FieldLayouts[0].SummaryDefinitions.Add( "PriceTotal", SummaryCalculator.Sum, "Price" ); summaryDef2.StringFormat = "Total={0:C}"; }
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