Back to Devexpress

PivotGridControl.HtmlImages Property

windowsforms-devexpress-dot-xtrapivotgrid-dot-pivotgridcontrol-47490655.md

latest4.8 KB
Original Source

PivotGridControl.HtmlImages Property

Gets or sets a collection of images which can be used in HTML string displayed in the field headers or values.

Namespace : DevExpress.XtraPivotGrid

Assembly : DevExpress.XtraPivotGrid.v25.2.dll

NuGet Package : DevExpress.Win.PivotGrid

Declaration

csharp
[DefaultValue(null)]
[DXCategory("Appearance")]
public virtual object HtmlImages { get; set; }
vb
<DefaultValue(Nothing)>
<DXCategory("Appearance")>
Public Overridable Property HtmlImages As Object

Property Value

TypeDefaultDescription
Objectnull

An image collection (DevExpress.Utils.ImageCollection or DevExpress.Utils.SvgImageCollection).

|

Remarks

To insert an image in an HTML string displayed in field values or field headers:

Example

This code snippet demonstrates how to handle the PivotGridControl.FieldValueDisplayText event to dispklay HTML in field values.

Tip

The live example HTML in Field Values is available in our demo center.

csharp
pivotGridControl.HtmlImages = DemoHelper.GetHtmlImages();
pivotGridControl.OptionsView.AllowHtmlDrawFieldValues = true;
pivotGridControl.FieldValueDisplayText += (sender, args) => {
    if(!args.IsPopulatingFilterDropdown && args.ValueType == PivotGridValueType.Value && args.Field.FieldName == "ProductName") {
        int categoryID = (int)args.CreateDrillDownDataSource().GetValue(0, "CategoryID");
        string prefix = string.Format("<image={0}> ", categoryID);
        string foreColor = DemoHelper.GetCategoryColor(categoryID);
        if(!string.IsNullOrEmpty(foreColor))
            prefix += string.Format("<color={0}>", foreColor);
        args.DisplayText = prefix + args.DisplayText;
    }
};
vb
pivotGridControl.HtmlImages = DemoHelper.GetHtmlImages()
pivotGridControl.OptionsView.AllowHtmlDrawFieldValues = True
AddHandler pivotGridControl.FieldValueDisplayText, Sub(sender, args)
    If Not args.IsPopulatingFilterDropdown AndAlso args.ValueType = PivotGridValueType.Value AndAlso args.Field.FieldName = "ProductName" Then
        Dim categoryID As Integer = CInt(Fix(args.CreateDrillDownDataSource().GetValue(0, "CategoryID")))
        Dim prefix As String = String.Format("<image={0}> ", categoryID)
        Dim foreColor As String = DemoHelper.GetCategoryColor(categoryID)
        If Not String.IsNullOrEmpty(foreColor) Then
            prefix &= String.Format("<color={0}>", foreColor)
        End If
        args.DisplayText = prefix & args.DisplayText
    End If
End Sub

See Also

HTML-inspired Text Formatting

PivotGridControl Class

PivotGridControl Members

DevExpress.XtraPivotGrid Namespace