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.
在本课中,您将学习如何设置显示业务对象的详细信息窗体的标题的格式。为此,将通过 BOModel |联系人节点的"对象标题格式"属性。
Note 注意
Before proceeding, take a moment to review the following lessons.
- Inherit from the Business Class Library Class (XPO/EF)
- Place an Action in a Different Location
在继续之前,请花点时间复习以下课程。
- 从商务舱库类 (XPO/EF) 继承
- 将操作放置在其他位置
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.
默认情况下,类的默认属性值在详细信息窗体标题中使用。FullName 属性是 Person 类的默认属性(通过默认属性属性指定)。由于联系人类是从 Person 继承的(请参阅从商务舱库的类继承(XPO、EF)),因此 FullName 属性也是联系人类中的默认属性。
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}".
执行以下步骤来指定自定义字幕格式。
- 通过双击"模型.设计Diffs.xafml"文件来调用模型编辑器。
- 在模型编辑器中,导航到 BOModel |MySolution.模块.业务对象节点。选择"联系人"节点,该节点定义"联系人"业务舱。在右侧,类设置由属性表示。
- 将 ObjectCaptionFormat 属性的默认值替换为 {0}0:部门}中的"{0}:FullName}"。
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.
设置对象标题格式时,可以显式指定格式字符串。例如,{0:文章No:0000,00}或{0:_sDateValue值:MM.yyyy}。有关格式设置的详细信息,请参阅格式指定器主题。
-
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.
-
运行 WinForms 或ASP.NET应用程序。调用联系人对象的详细信息窗体。标题必须设置为值,如下图所示。
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 19.2\Components\eXpressApp Framework\MainDemo by default. The ASP.NET version is available online at http://demos.devexpress.com/XAF/MainDemo/
您可以在本课中为模型调用的模型编辑器中所做的更改。主演示模块项目。主演示应用程序安装在%PUBLIC%\Documents\DevExpress Demos 19.2\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.
XAF开发成品案例参考
如果您觉得阅读本文对您有帮助,请点一下“推荐”按钮,您的“推荐”将是我最大的写作动力!欢迎各位转载,但是未经作者本人同意,转载文章之后必须在文章页面明显位置给出作者和原文连接,否则保留追究法律责任的权利。
作者博客: http://www.cnblogs.com/foreachlife
欢迎加入CIIP框架\XAF技术应用交流群: 336090194 群文件中有更多相关工具及文档资料
转载请注明出处。多谢!
欢迎加我微信: admiralcn 或扫码:

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· 周边上新:园子的第一款马克杯温暖上架
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· Ollama——大语言模型本地部署的极速利器
· DeepSeek如何颠覆传统软件测试?测试工程师会被淘汰吗?
· 使用C#创建一个MCP客户端