Back to Devexpress

PivotGridControl.ValueImages Property

windowsforms-devexpress-dot-xtrapivotgrid-dot-pivotgridcontrol-3003a5f6.md

latest6.0 KB
Original Source

PivotGridControl.ValueImages Property

Gets or sets the source of images that are available for display within field values.

Namespace : DevExpress.XtraPivotGrid

Assembly : DevExpress.XtraPivotGrid.v25.2.dll

NuGet Package : DevExpress.Win.PivotGrid

Declaration

csharp
[DefaultValue(null)]
public object ValueImages { get; set; }
vb
<DefaultValue(Nothing)>
Public Property ValueImages As Object

Property Value

TypeDefaultDescription
Objectnull

An object that is an image collection providing images for the PivotGridControl‘s field values.

|

Remarks

To assign images to field values handle the PivotGridControl.FieldValueImageIndex event.

The ValueImages property accepts the following image collections:

Example

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

The image below shows the result.

csharp
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;
}
vb
Imports DevExpress.XtraPivotGrid

Private Shared CategoryNames As String() = New String() {"Beverages", "Condiments", _
  "Confections", "Dairy Products", "Grains/Cereals", "Meat/Poultry", "Produce", "Seafood"}
Public Shared Function GetCategoryIndexByName(ByVal name As Object) As Integer
   If Not name Is Nothing Then
         Dim i As Integer = 0
         While i < CategoryNames.Length
            If CategoryNames(i) = name.ToString() Then
               Return i
            End If
            i += 1
         End While
   End If
   Return -1
End Function
' ...
Private Sub pivotGridControl1_FieldValueImageIndex(ByVal sender As Object, ByVal e As PivotFieldImageIndexEventArgs)
    If e.Field = fieldCategoryName1 AndAlso e.ValueType = PivotGridValueType.Value Then
        e.ImageIndex = GetCategoryIndexByName(e.Value)
    End If
    If e.ValueType = PivotGridValueType.GrandTotal AndAlso e.IsColumn = False Then
        e.ImageIndex = 8
    End If
End Sub

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the ValueImages 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-implement-custom-drawing-for-the-chartcontrol-that-is-bound-to-the-pivotgrid-control/CS/WindowsFormsApplication8/Form1.cs#L31

csharp
imgList.Images.AddRange(CreateImages(seriesColors));
pivotGridControl1.ValueImages = imgList;

winforms-implement-custom-drawing-for-the-chartcontrol-that-is-bound-to-the-pivotgrid-control/VB/WindowsFormsApplication8/Form1.vb#L27

vb
imgList.Images.AddRange(CreateImages(seriesColors))
    pivotGridControl1.ValueImages = imgList
End Sub

See Also

FieldValueImageIndex

HeaderImages

PivotGridControl Class

PivotGridControl Members

DevExpress.XtraPivotGrid Namespace