Format a Business Object Caption

In this lesson, you will learn how to format the caption of a detail form that displays a business object. For this purpose, the caption of a Contact object's detail form will be specified via the BOModel | Contact node's ObjectCaptionFormat property.

Note

Before proceeding, take a moment to review the following lessons.

By default, the class' default property value is used in the detail form caption. The FullName property is the Person class' default property (specified via the DefaultProperty attribute). As the Contact class is inherited from Person (see Inherit from the Business Class Library's Class (XPO, EF)), the FullName property is also the default property in the Contact class.

Tutorial_UIC_Lesson3_1

Perform the following steps to specify the custom caption format.

  • Invoke the Model Editor by double-clicking the Model.DesignedDiffs.xafml file in the MySolution.Module project.
  • In the Model Editor, navigate to the BOModel | MySolution.Module.BusinessObjects node. Select the Contact node, which defines the Contact business class. To the right, the class settings are represented by properties.
  • Replace the default value of the ObjectCaptionFormat property with "{0:FullName} from the {0:Department}".

    Note

    When setting the object caption format, you can explicitly specify the format string. For instance, {0:ArticleNo:0000,00#} or {0:PeriodDateValue:MM.yyyy}. For more information about formatting, refer to the Format Specifiers topic.

    Tutorial_UIC_Lesson3_2

  • Run the WinForms or ASP.NET application. Invoke a detail form for a Contact object. The caption must be set to a value, as shown in the following image.

    Tutorial_UIC_Lesson3_3

You can see the changes made in this lesson in the Model Editor invoked for the Model.DesignedDiffs.xafml file located in the Main Demo | MainDemo.Module project. The MainDemo application is installed in %PUBLIC%\Documents\DevExpress Demos 18.1\Components\eXpressApp Framework\MainDemo by default. The ASP.NET version is available online at http://demos.devexpress.com/XAF/MainDemo/.

Note

You can use the ObjectCaptionFormatAttribute to specify the object caption in code.

 

Next Lesson: Assign a Standard Image

See Also