windowsforms-devexpress-dot-xtrapivotgrid-dot-pivotgridcontrol-47490655.md
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
[DefaultValue(null)]
[DXCategory("Appearance")]
public virtual object HtmlImages { get; set; }
<DefaultValue(Nothing)>
<DXCategory("Appearance")>
Public Overridable Property HtmlImages As Object
| Type | Default | Description |
|---|---|---|
| Object | null |
An image collection (DevExpress.Utils.ImageCollection or DevExpress.Utils.SvgImageCollection).
|
To insert an image in an HTML string displayed in field values or field headers:
Set the PivotGridOptionsView.AllowHtmlDrawHeaders or the PivotGridOptionsView.AllowHtmlDrawFieldValues property to true
Create a ImageCollection object, add images to it and assign this ImageCollection to the HtmlImages property.
Insert an image tag in the HTML string, use collection indexes to refer to the images.
Assign an HTML string to the PivotGridFieldBase.Caption property to display it in the field’s header or handle the PivotGridControl.FieldValueDisplayText event and use the PivotFieldDisplayTextEventArgs.DisplayText property to display HTML in the field’s value.
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.
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;
}
};
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