windowsforms-devexpress-dot-xtraprinting-dot-preview-dot-imageeditoroptions.md
A collection of images that an end user can load to the image editor in Print Preview.
Namespace : DevExpress.XtraPrinting.Preview
Assembly : DevExpress.XtraPrinting.v25.2.dll
NuGet Package : DevExpress.Win.Printing
public ICollection<ImageCollectionItem> PredefinedImages { get; }
Public ReadOnly Property PredefinedImages As ICollection(Of ImageCollectionItem)
| Type | Description |
|---|---|
| ICollection<ImageCollectionItem> |
The image editor’s image collection.
|
Specify the PredefinedImages property to add the 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.
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);
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)
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