Back to Devexpress

PivotGridFieldBase.Name Property

corelibraries-devexpress-dot-xtrapivotgrid-dot-pivotgridfieldbase-b972171c.md

latest7.7 KB
Original Source

PivotGridFieldBase.Name Property

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

Declaration

csharp
[Browsable(false)]
[DefaultValue("")]
public virtual string Name { get; set; }
vb
<Browsable(False)>
<DefaultValue("")>
Public Overridable Property Name As String

Property Value

TypeDefaultDescription
StringString.Empty

A string which specifies the field’s name.

|

Remarks

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:

csharp
pivotGridControl1.RetrieveFields();
foreach(PivotGridField field in pivotGridControl1.Fields)
field.Name = "field" + (field.DataBinding as DataSourceColumnBindingBase).ColumnName;
vb
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

csharp
foreach (PivotGridField field in pivotGridControl1.Fields){
    field.Name = "field" + (field.DataBinding as DataSourceColumnBinding).ColumnName;
}

winforms-pivot-grid-hide-the-grand-total-column-and-text-labels/CS/RemoveGridLinesExample/Form1.cs#L34

csharp
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

csharp
PivotGridField fieldYear = new PivotGridField("", PivotArea.ColumnArea);
fieldYear.Name = "FieldYear";
fieldYear.DataBinding = new DataSourceColumnBinding("Date", PivotGroupInterval.DateYear);

winforms-pivotgrid--display-the-difference-of-income-and-outlay-in-totals/CS/PivotGridCustomSummaryExample/Form1.cs#L53

csharp
{
    if (e.DataField.Name == "fieldValue")
    {

winforms-pivot-access-other-cell-value-while-calculating-the-current-cell/CS/WinAppCustomCellValue/Form1.cs#L26

csharp
// 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

vb
For Each field As PivotGridField In pivotGridControl1.Fields
    field.Name = "field" & TryCast(field.DataBinding, DataSourceColumnBinding).ColumnName
Next

winforms-pivot-grid-hide-the-grand-total-column-and-text-labels/VB/RemoveGridLinesExample/Form1.vb#L40

vb
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

vb
Dim fieldYear As New PivotGridField("Date", PivotArea.ColumnArea)
fieldYear.Name = "FieldYear"
fieldYear.Caption = fieldYear.Name

winforms-pivotgrid--display-the-difference-of-income-and-outlay-in-totals/VB/PivotGridCustomSummaryExample/Form1.vb#L43

vb
Private Sub pivotGridControl1_CustomSummary(ByVal sender As Object, ByVal e As PivotGridCustomSummaryEventArgs)
    If e.DataField.Name = "fieldValue" Then
        If CustomSummaryHelper.ShouldCalculateCustomValue(fieldType, e) Then

winforms-pivot-access-other-cell-value-while-calculating-the-current-cell/VB/WinAppCustomCellValue/Form1.vb#L23

vb
' Calculates the 'Percent' field values.
If e.DataField.Name = "PercentOfBeverages" Then
    ' Do not display grand total values.

See Also

GetFieldByName(String)

PivotGridFieldBase Class

PivotGridFieldBase Members

DevExpress.XtraPivotGrid Namespace