PivotGridControl.FieldValueImageIndex Event

Enables images to be shown within column and row headers.

Namespace: DevExpress.XtraPivotGrid

Assembly: DevExpress.XtraPivotGrid.v20.1.dll

Declaration

public event PivotFieldImageIndexEventHandler FieldValueImageIndex
Public Event FieldValueImageIndex As PivotFieldImageIndexEventHandler

Event Data

The FieldValueImageIndex event's data class is PivotFieldImageIndexEventArgs. The following properties provide information specific to this event:

Property Description
CustomTotal Gets the custom total that corresponds to the currently processed column/row header.
Data For internal use. Inherited from PivotFieldValueEventArgsBase<T>.
DataField Gets the data field that identifies the processed value.
Field Gets the field being processed.
FieldIndex Gets the field position among the visible fields within the header area.
ImageIndex Gets or sets the index of the image to display within the currently processed column/row header.
IsCollapsed Gets whether the processed field value is collapsed.
IsColumn Gets whether the field is displayed within the Column Header Area.
IsOthersValue Gets whether the current header corresponds to the "Others" row/column.
Item For internal use. Inherited from PivotFieldValueEventArgsBase<T>.
MaxIndex Gets the maximum row index (for row fields) or column index (for column fields) that corresponds to the field value currently being processed.
MinIndex Gets the minimum row index (for row fields) or column index (for column fields) that corresponds to the field value currently being processed.
ThreadSafeArgs Gets an event parameter that provides thread-safe access to event data.
Value Gets the column field or row field value that corresponds to the currently processed column/row header.
ValueType Gets the type of the currently processed column/row header.

Remarks

The FieldValueImageIndex event lets you assign images for individual field values, total headers and grand total headers. An image can be assigned to a header via the PivotFieldImageIndexEventArgs.ImageIndex parameter which represents the index of the image in the PivotGridControl.ValueImages list.

The type of the currently processed header is determined by the ValueType parameter. If the FieldValueImageIndex event is raised for a field value or total header the Field parameter identifies the corresponding column field or row field. If the FieldValueImageIndex event is raised for a grand total header the Field property will return null.

NOTE

To access event data while an asynchronous operation is being performed, use a thread-safe event parameter returned by the PivotFieldImageIndexEventArgs.ThreadSafeArgs property. To learn more, see Asynchronous Mode.

Examples

The following sample code handles the PivotGridControl.FieldValueImageIndex event to display images within the "Category Name" field values.

The image below shows the result.

FieldValueImageIndex-event

using DevExpress.XtraPivotGrid;

static string[] CategoryNames = new string[] {"Beverages", "Condiments", "Confections", 
  "Dairy Products", "Grains/Cereals", "Meat/Poultry", "Produce", "Seafood"};
public static int GetCategoryIndexByName(object name) {
    if(name != null)
        for(int i = 0; i < CategoryNames.Length; i++)
            if(CategoryNames[i] == name.ToString()) return i;
        return -1;
}

// ...
private void pivotGridControl1_FieldValueImageIndex(object sender, 
  PivotFieldImageIndexEventArgs e) {
    if(e.Field == fieldCategoryName && e.ValueType == PivotGridValueType.Value) 
        e.ImageIndex = GetCategoryIndexByName(e.Value);
    if (e.ValueType == PivotGridValueType.GrandTotal && e.IsColumn == false)
        e.ImageIndex = 8;
}
See Also