Skip to main content
.NET Framework 4.5.2+

ObjectFormatter.Format(String, Object, EmptyEntriesMode) Method

Replaces format items in the specified string with the values of the specified object’s properties. Allows you to specify the EmptyEntriesMode mode of processing the passed string.

Namespace: DevExpress.Persistent.Base

Assembly: DevExpress.ExpressApp.v22.2.dll

NuGet Package: DevExpress.ExpressApp


public static string Format(
    string format,
    object obj,
    EmptyEntriesMode mode


Name Type Description
format String

A string that contains zero or more format items.

obj Object

An object whose property values are used in the formatting of the passed string.

mode EmptyEntriesMode

An EmptyEntriesMode enumeration value that specifies the mode of processing the passed string.


Type Description

A string in which the format items have been replaced by the string representations of the specified object’s property values.


The Format method treats all the format items in the passed string as the property names of the passed object. It replaces all the format items in the passed string with the corresponding property values of the passed object.

This method can be used to create calculated properties in persistent classes. The following code snippet illustrates how to define the non-persistent read-only FullName property. This property’s value is calculated from the FirstName and LastName properties using the Format method.

using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl.EF;
using System.ComponentModel.DataAnnotations;


public class Contact : BaseObject {
    public virtual string FirstName { get; set; }
    public virtual string LastName { get; set; }
    public string FullName {
        get {
            return ObjectFormatter.Format(
                "{LastName}, {FirstName}", this,
                EmptyEntriesMode.RemoveDelimiterWhenEntryIsEmpty );

// Make sure that you use options.UseChangeTrackingProxies() in your DbContext settings.

The following image illustrates a Detail View for the implemented Contact class.


If custom processing of the strings passed to the Format method is required, handle the ObjectFormatter.CustomFormatObject event.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Format(String, Object, EmptyEntriesMode) method.


The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also