Skip to main content
All docs
V24.2

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

IFormatStringStorage Interface

In This Article

Allows you to add a custom format string to the DateTime format string list displayed in the Format String editor.

Namespace: DevExpress.XtraReports.Web.ReportDesigner.Services

Assembly: DevExpress.XtraReports.v24.2.Web.dll

NuGet Package: DevExpress.Web.Reporting.Common

#Declaration

public interface IFormatStringStorage

#Remarks

Register a service that implements the IFormatStringStorage interface to add a format string to the list of DateTime format strings available in the Format String Editor.

The following code snippet implements a service that adds a d format string to the strings shown in the DateTime category:

Format String editor and a custom format string using IFormatStringStorage service

using System;
using System.Collections.Generic;
using DevExpress.XtraReports.Web.ReportDesigner.Services;

public class CustomFormatStringStorage : IFormatStringStorage {
    protected Dictionary<string, string[]> CustomSet { get; private set; }
    public virtual Dictionary<string, string[]> GetAllPatterns() {
        CustomSet = new Dictionary<string, string[]> {
            { "System.DateTime", new string[] { "d" } }
        };
        return CustomSet;
    }

    public bool Save(string typeString, string pattern) {
         return false;
    }

    public bool Remove(string typeString, string pattern) {
         return false;
    }
}

Register the service at application startup:

using Microsoft.AspNetCore.Builder;
using DevExpress.XtraReports.Web.ReportDesigner.Services;

var builder = WebApplication.CreateBuilder(args);
// ...
builder.Services.AddScoped<IFormatStringStorage, CustomFormatStringStorage>();
using DevExpress.XtraReports.Web.ReportDesigner.Services;
// ...
 protected void Application_Start() {
  // ...
  DefaultReportDesignerContainer.Register<IFormatStringStorage, CustomFormatStringStorage>();
 }
See Also