Skip to main content

EditingFieldExtensionsWin.RegisterEditor(String, String, String, RepositoryItem) Method

Registers a custom editor to be used for changing control content in Print Preview.

Namespace: DevExpress.XtraPrinting.Preview

Assembly: DevExpress.XtraPrinting.v23.1.dll

NuGet Package: DevExpress.Win.Printing

Declaration

public virtual bool RegisterEditor(
    string name,
    string displayName,
    string category,
    RepositoryItem repositoryItem
)

Parameters

Name Type Description
name String

The name of a custom editor.

displayName String

The display name of a custom editor.

category String

The name of a category to which an editor should be added.

repositoryItem RepositoryItem

A RepositoryItem descendant providing the required functionality.

Returns

Type Description
Boolean

true if an editor has been successfully registered; otherwise, false.

Remarks

If an editor with the same name already exists, the specified editor will not be registered.

Example

Tip

A complete sample project is available in the DevExpress Code Examples database at https://supportcenter.devexpress.com/ticket/details/t453603/how-to-use-custom-controls-for-editing-report-content-in-print-preview.

To provide a custom editor to be used for editing a control’s content in Print Preview, do the following.

  1. Create a new instance of an appropriate RepositoryItem descendant and specify its settings as required.

    using DevExpress.XtraEditors.Repository;
    //...
    
    // Create a new combo box editor with required settings.
    RepositoryItemComboBox repositoryItemComboBox = new RepositoryItemComboBox() {
        TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor,
        ImmediatePopup = true
    };
    
    // Populate the created editor with items.
    for (int i = 0; i < 20; i++)
        repositoryItemComboBox.Items.Add(string.Format("Item {0}", i + 1));
    
  2. Next, register the editor in a new Custom category by calling the EditingFieldExtensionsWin.RegisterEditor method.

    using DevExpress.XtraPrinting.Preview;
    // ...
    
    EditingFieldExtensionsWin.Instance.RegisterEditor
        ("ComboBoxEditor", "ComboBox Editor", "Custom", repositoryItemComboBox);
    
  3. Assign the created editor to a required control using the TextEditOptions.EditorName property.

    using DevExpress.XtraReports.UI;
    // ...
    
    XtraReport1 report = new XtraReport1();
    
    report.xrLabel1.EditOptions.Enabled = true;
    report.xrLabel1.EditOptions.EditorName = "ComboBoxEditor";
    

When you need to use the standard text editor with a custom mask, you can register it using the EditingFieldExtensionsWin.RegisterMaskEditor method. This method accepts the mask type and mask string as parameters instead of a repository item.

using DevExpress.XtraPrinting.Preview;
// ...

// Register a text editor with a custom mask.
EditingFieldExtensionsWin.Instance.RegisterMaskEditor("PhoneNumberEditor", "Phone Number Editor", 
    "Custom", DevExpress.XtraEditors.Mask.MaskType.Simple, "(999)000-00-00");
See Also