windowsforms-devexpress-dot-xtraprinting-dot-preview-dot-editingfieldextensionswin-dot-registerimagecollectioneditor-x28-string-string-ienumerable-image-boolean-x29.md
Registers an image editor with a collection of predefined images to be used for changing image content in Print Preview.
Namespace : DevExpress.XtraPrinting.Preview
Assembly : DevExpress.XtraPrinting.v25.2.dll
NuGet Package : DevExpress.Win.Printing
public virtual bool RegisterImageCollectionEditor(
string name,
string displayName,
IEnumerable<Image> images,
bool sizeOptionsEnabled
)
Public Overridable Function RegisterImageCollectionEditor(
name As String,
displayName As String,
images As IEnumerable(Of Image),
sizeOptionsEnabled As Boolean
) As Boolean
| Name | Type | Description |
|---|---|---|
| name | String |
The name of the registered image collection editor.
| | displayName | String |
The display name of the registered image collection editor.
| | images | IEnumerable<Image> |
The editor’s image collection.
| | sizeOptionsEnabled | Boolean |
true if the editor allows end users to set up the image’s size and alignment options; otherwise, false.
|
| Type | Description |
|---|---|
| Boolean |
true if the image list has been successfully registered; otherwise, false.
|
Use this method to register an image editor with a collection of predefined images in the application.
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using DevExpress.XtraPrinting.Preview;
//...
List<Image> images = new List<Image>();
foreach (var file in Directory.GetFiles("../../Flags/", "*.png")) {
Image img = Image.FromFile(file);
if (img != null) {
images.Add(img);
}
}
EditingFieldExtensionsWin.Instance.RegisterImageCollectionEditor("Nationality", "Nationality", images, false);
Imports System.Collections.Generic
Imports System.Drawing
Imports System.IO
Imports DevExpress.XtraPrinting.Preview
'...
Dim images As New List(Of Image)()
For Each file In Directory.GetFiles("../../Flags/", "*.png")
Dim img As Image = Image.FromFile(file)
If img IsNot Nothing Then
images.Add(img)
End If
Next file
EditingFieldExtensionsWin.Instance.RegisterImageCollectionEditor("Nationality", "Nationality", images, False)
To use this editor for image editing in Print Preview, set a XRPictureBox control’s EditOptions | Enabled property to true and the EditOptions | EditorName property - to the registered editor’s name.
Set image edit options in the end-user Report Designer’ Property Grid.
The following sample demonstrates how to do this in code.
using DevExpress.XtraReports.UI;
//...
XtraReport1 report = new XtraReport1();
XRPictureBox pictureBox = report.Bands["ReportHeader"].FindControl("xrPictureBox1", true) as XRPictureBox;
pictureBox.EditOptions.Enabled = true;
pictureBox.EditOptions.EditorName = "Nationality";
Imports DevExpress.XtraReports.UI
'...
Private report As New XtraReport1()
Private pictureBox As XRPictureBox = TryCast(report.Bands("ReportHeader").FindControl("xrPictureBox1", True), XRPictureBox)
pictureBox.EditOptions.Enabled = True
pictureBox.EditOptions.EditorName = "Nationality"
When an end user clicks the Picture Box in Print Preview, the assigned editor activates. This editor allows end users to choose a predefined image, set up its size and alignment, and reset the initial image.
Note
Use the RegisterImageEditor(String, String, ImageEditorOptions) method instead if you need to add the Brush Options and/or Load Image menu items as well.
See Also
EditingFieldExtensionsWin Class