corelibraries-devexpress-dot-xtrapivotgrid-dot-pivotgridfieldbase-b972171c.md
Gets or sets the field’s name.
Namespace : DevExpress.XtraPivotGrid
Assembly : DevExpress.PivotGrid.v25.2.Core.dll
NuGet Packages : DevExpress.PivotGrid.Core, DevExpress.Win.Navigation
[Browsable(false)]
[DefaultValue("")]
public virtual string Name { get; set; }
<Browsable(False)>
<DefaultValue("")>
Public Overridable Property Name As String
| Type | Default | Description |
|---|---|---|
| String | String.Empty |
A string which specifies the field’s name.
|
PivotGridFieldBase objects can be directly accessed in code by their names.
Use the Name property to assign a name to a PivotGridFieldBase object created at runtime. This name can be used to determine fields in a stored layout. For example, the following code snippet sets field names for all fields in the Pivot Grid:
pivotGridControl1.RetrieveFields();
foreach(PivotGridField field in pivotGridControl1.Fields)
field.Name = "field" + (field.DataBinding as DataSourceColumnBindingBase).ColumnName;
pivotGridControl1.RetrieveFields()
For Each field As PivotGridField In pivotGridControl1.Fields
field.Name = "field" & (TryCast(field.DataBinding, DataSourceColumnBindingBase)).ColumnName
Next field
To retrieve a field from the control’s field collection by its name use the PivotGridFieldCollectionBase.GetFieldByName method.
The following code snippets (auto-collected from DevExpress Examples) contain references to the Name property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
winforms-pivot-grid-connect-to-an-olap-datasource/CS/WinOlapRetrieveFieldsExample/Form1.cs#L27
foreach (PivotGridField field in pivotGridControl1.Fields){
field.Name = "field" + (field.DataBinding as DataSourceColumnBinding).ColumnName;
}
fieldYear.DataBinding = new DataSourceColumnBinding("Date", PivotGroupInterval.DateYear);
fieldYear.Name = "FieldYear";
fieldYear.Caption = fieldYear.Name;
winforms-pivot-change-summarydisplaytype-in-context-menu/CS/WindowsApplication34/Form1.cs#L24
PivotGridField fieldYear = new PivotGridField("", PivotArea.ColumnArea);
fieldYear.Name = "FieldYear";
fieldYear.DataBinding = new DataSourceColumnBinding("Date", PivotGroupInterval.DateYear);
{
if (e.DataField.Name == "fieldValue")
{
// Calculates the 'Percent' field values.
if (e.DataField.Name == "PercentOfBeverages") {
// Hides grand total values.
winforms-pivot-grid-connect-to-an-olap-datasource/VB/WinOlapRetrieveFieldsExample/Form1.vb#L28
For Each field As PivotGridField In pivotGridControl1.Fields
field.Name = "field" & TryCast(field.DataBinding, DataSourceColumnBinding).ColumnName
Next
fieldYear.DataBinding = New DataSourceColumnBinding("Date", PivotGroupInterval.DateYear)
fieldYear.Name = "FieldYear"
fieldYear.Caption = fieldYear.Name
winforms-pivot-change-summarydisplaytype-in-context-menu/VB/WindowsApplication34/Form1.vb#L27
Dim fieldYear As New PivotGridField("Date", PivotArea.ColumnArea)
fieldYear.Name = "FieldYear"
fieldYear.Caption = fieldYear.Name
Private Sub pivotGridControl1_CustomSummary(ByVal sender As Object, ByVal e As PivotGridCustomSummaryEventArgs)
If e.DataField.Name = "fieldValue" Then
If CustomSummaryHelper.ShouldCalculateCustomValue(fieldType, e) Then
' Calculates the 'Percent' field values.
If e.DataField.Name = "PercentOfBeverages" Then
' Do not display grand total values.
See Also