Skip to main content

ImageEditorOptions.PredefinedImages Property

A collection of images that an end user can load to the image editor in Print Preview.

Namespace: DevExpress.XtraPrinting.Preview

Assembly: DevExpress.XtraPrinting.v24.2.dll

Declaration

public ICollection<ImageCollectionItem> PredefinedImages { get; }

Property Value

Type Description
ICollection<ImageCollectionItem>

The image editor’s image collection.

Remarks

Specify the PredefinedImages property to add the Predefined Images Menu Item item to the image editor’s menu. This item allows end users to choose one of the predefined images and load it to the editor.

Predefined Images

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

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);

Do not specify image captions or set the AllowSearchPredefinedImages property to false if search within the image collection is not required.

If you want to allow end users to only choose an image in the predefined collection, you can use the RegisterImageCollectionEditor method instead of the RegisterImageEditor(String, String, ImageEditorOptions) method. The RegisterImageCollectionEditor method takes an image collection directly, as a parameter.

See Also