Skip to main content
All docs
V24.1

IFormatStringStorage Interface

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.1.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