Back to Devexpress

IFormatStringStorage Interface

xtrareports-devexpress-dot-xtrareports-dot-web-dot-reportdesigner-dot-services-48f35ad9.md

latest3.0 KB
Original Source

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.v25.2.Web.dll

NuGet Package : DevExpress.Web.Reporting.Common

Declaration

csharp
public interface IFormatStringStorage
vb
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:

csharp
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:

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

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

See Also

IFormatStringStorage Members

DevExpress.XtraReports.Web.ReportDesigner.Services Namespace