The requested page is not available for the requested platform. You are viewing the content for Default platform.

XRZipCode Class

Renders a numeric postal code that is used to identify the mail address in some countries. This control is not related to the Zone Improvement Plan (ZIP) code used by the United States Postal Service.

Namespace: DevExpress.XtraReports.UI

Assembly: DevExpress.XtraReports.v19.1.dll


public class XRZipCode :
Public Class XRZipCode
    Inherits XRFieldEmbeddableControl


The XRZipCode control renders a numeric postal code that is used to identify the mail address in some countries. This control is not related to the Zone Improvement Plan (ZIP) code used by the United States Postal Service.


A postal code can only display numeric characters and dashes. Other characters are displayed as empty boxes.

To add this control to a report, drag the XRZipCode item from the DX:19.1: Report Controls Toolbox tab and drop it onto the report.


To specify the text for the control, use the XRZipCode.Text property.

Bind a Postal Code to Data

The Text property can be bound to a data field obtained from the data source. To do this, click the control's smart tag and in its actions list, expand the Expression drop-down list and select the required data field.


Clicking the Expression option's ellipsis button invokes the Expression Editor, in which you can construct a complex binding expression involving two or more data fields.

See the Bind Report Controls to Data topic to learn more about available data binding modes and creating data-aware controls.

Add a Zip Code to End-User Report Designers

The Toolbox of End-User Report Designers does not contain the XRZipCode control by default.

To register this control, do one of the following (depending on your target platform):

  • Windows Forms

    Add the control to the Toolbox of the End-User Report Designer for WinForms by handling the XRDesignMdiController.DesignPanelLoaded event as shown in the following code snippet:

    using System.Drawing.Design;
    using DevExpress.XtraReports.UI;
    using DevExpress.XtraReports.UserDesigner;
    private void reportDesigner1_DesignPanelLoaded(object sender, DesignerLoadedEventArgs e) {
        IToolboxService ts = (IToolboxService)e.DesignerHost.GetService(typeof(IToolboxService));
        ToolboxItem item = new ToolboxItem(typeof(XRZipCode));
        item.DisplayName = "Zip Code";

    Add the Zip Code item to the context menu invoked when you right-click a data field in the Field List and drop it onto the report.

    using System.Drawing;
    using System.ComponentModel;
    using DevExpress.XtraReports.UserDesigner;
    using DevExpress.XtraReports.Design;
    using DevExpress.XtraReports.Design.Commands;
    using DevExpress.XtraReports.UI;
    private void Form1_Load(object sender, EventArgs e) {
        reportDesigner1.AddService(typeof(IMenuCreationService), new CustomMenuCreationService());
    class CustomMenuCreationService : IMenuCreationService {
        public MenuCommandDescription[] GetCustomMenuCommands() {
            return new MenuCommandDescription[] {};            
        public void ProcessMenuItems(MenuKind menuKind, MenuItemDescriptionCollection items) {
            if (menuKind == MenuKind.FieldDrop) {
                int index = items.IndexOf(BandCommands.BindFieldToXRBarCode);
                if (index < 0)
                ToolboxBitmapAttribute bitmapAttribute = (ToolboxBitmapAttribute)TypeDescriptor.
                Image itemImage = bitmapAttribute.GetImage(typeof(XRZipCode), false);
                MenuItemDescription zipCodeItem = new MenuItemDescription("Zip Code", itemImage, 
                items.Insert(index+1, zipCodeItem);
  • WPF

    Add the control to the Toolbox of the End-User Report Designer for WPF by calling the static ReportDesigner.RegisterControl<T> method and passing an appropriate diagram item and control icon as parameters.

    using System.Windows.Media.Imaging;
    using DevExpress.Xpf.Reports.UserDesigner;
    using DevExpress.Xpf.Reports.UserDesigner.XRDiagram;
    using DevExpress.XtraReports.UI;
    using DevExpress.Utils;
    using DevExpress.Xpf.Core;
    var icon = (ImageSource)new ImageSelectorExtension {
        Source = AssemblyHelper.GetResourceUri(typeof(ReportDesigner).Assembly,
        SvgSource = AssemblyHelper.GetResourceUri(typeof(ReportDesigner).Assembly,
    ReportDesigner.RegisterControl<XRZipCode>(() => new DefaultXRControlDiagramItem(), icon);

    Add the control to the Web End-User Report Designer using the client-side ASPxClientReportDesigner.CustomizeToolbox event as demonstrated below.

    <script type="text/javascript" id="script">
        function customizeToolbox(s, e) {
            var info = e.ControlsFactory.getControlInfo("XRZipCode");
            info.isToolboxItem = true;
    <dx:ASPxReportDesigner ID="ASPxReportDesigner1" runat="server">      
        <ClientSideEvents CustomizeToolbox="customizeToolbox"/>  


See Also