Back to Devexpress

ImageCollectionItem Class

windowsforms-devexpress-dot-xtraprinting-dot-preview-e5bde3ff.md

latest4.0 KB
Original Source

ImageCollectionItem Class

An object that provides an image and its caption.

Namespace : DevExpress.XtraPrinting.Preview

Assembly : DevExpress.XtraPrinting.v25.2.dll

NuGet Package : DevExpress.Win.Printing

Declaration

csharp
public class ImageCollectionItem
vb
Public Class ImageCollectionItem

Remarks

When you register a custom image editor (see RegisterImageEditor(String, String, ImageEditorOptions)) to edit the XRPictureBox‘s content in Print Preview, you can specify the PredefinedImages image collection. This collection is displayed in the image editor and enables end users to select one of the predefined images.

Create the ImageCollectionItem objects to populate the PredefinedImages image collection. Specify the Image and Caption (optionally) properties for each item.

The following code snippet demonstrates how you can specify the PredefinedImages collection.

csharp
using System.Collections.Generic;
using System.IO;
using DevExpress.XtraPrinting.Preview;
using System.Drawing;

//...

Dictionary<string, Image> images = new Dictionary<string, Image>();
foreach (var file in Directory.GetFiles("Images/Flags", "*.png")) {
    Image img = Image.FromFile(file);
    if (img != null) {
        string imageName = Path.GetFileNameWithoutExtension(file);
        images.Add(imageName, img);
    }
};
ImageEditorOptions imageEditorOptions = new ImageEditorOptions() {
    AllowLoadImage = false,
    AllowChangeSizeOptions = false,
    AllowDraw = false,
    AllowClear = true
};
foreach (var image in images)
    imageEditorOptions.PredefinedImages.Add(new ImageCollectionItem(image.Value, image.Key));
EditingFieldExtensionsWin.Instance.RegisterImageEditor("Nationality", "Nationality", imageEditorOptions);
vb
Option Infer On

Imports System.Collections.Generic
Imports System.IO
Imports DevExpress.XtraPrinting.Preview
Imports System.Drawing

'...

Private images As New Dictionary(Of String, Image)()
For Each file In Directory.GetFiles("Images/Flags", "*.png")
    Dim img As Image = Image.FromFile(file)
    If img IsNot Nothing Then
        Dim imageName As String = Path.GetFileNameWithoutExtension(file)
        images.Add(imageName, img)
    End If
Next file
Dim imageEditorOptions As New ImageEditorOptions() With {
    .AllowLoadImage = False,
    .AllowChangeSizeOptions = False,
    .AllowDraw = False,
    .AllowClear = True
}
For Each image In images
    imageEditorOptions.PredefinedImages.Add(New ImageCollectionItem(image.Value, image.Key))
Next image
EditingFieldExtensionsWin.Instance.RegisterImageEditor("Nationality", "Nationality", imageEditorOptions)

Note

If you do not set captions for all Image Collection Items, search is not available in the image editor’s predefined collection.

Inheritance

Object ImageCollectionItem

See Also

ImageCollectionItem Members

DevExpress.XtraPrinting.Preview Namespace