Change Field Layout and Visibility in a List View 在列表视图中更改字段布局和可见性
This lesson will guide you through the steps needed to select columns displayed in the List View. For this purpose, the Contact List View will be used. At runtime, you can right-click a column header and activate the Column Chooser, then drag invisible columns from the Column Chooser window to the grid control. To set the default table layout, you need to customize it at design-time.
本课将指导您完成选择列表视图中显示的列所需的步骤。为此,将使用联系人列表视图。在运行时,您可以右键单击列标题并激活列选择器,然后将不可见的列从列选择器窗口拖动到网格控件。要设置默认表布局,需要在设计时对其进行自定义。
Note 注意
Before proceeding, take a moment to review the Place an Action in a Different Location lesson.
在继续之前,请花点时间复习"将操作置于不同位置"课程。
In a WinForms application, the customizations made using the Runtime Column Chooser are persisted in a Model.user.xafml file, located in the application folder by default. In an ASP.NET application, you may need to set the SaveListViewStateInCookies property of the Options node and the SaveStateInCookies property of the corresponding Views | <ListView> node to "true". This enables you to save the List View state between sessions in a user's browser cookies, allowing each end-user to customize the List View individually. The set of columns visible by default is generated based on rules described in the List View Column Generation article. Customizing the default column set may be required. To make required columns visible or invisible within the List View by default, use the Model Editor.
在 WinForms 应用程序中,使用运行时列选择器进行的自定义将保留在默认情况下位于应用程序文件夹中的 Model.user.xafml 文件中。在ASP.NET应用程序中,您可能需要设置选项节点的"存储列表"InCookies 属性和相应视图的 SaveStateInCookies 属性 |<ListView>节点"true"。这使您能够在用户的浏览器 Cookie 中的会话之间保存列表视图状态,从而允许每个最终用户单独自定义列表视图。默认情况下可见的列集基于列表视图列生成文章中描述的规则生成。可能需要自定义默认列集。要使所需列在默认情况下在列表视图中可见或不可见,请使用模型编辑器。
-
Invoke the Model Editor for the MySolution.Module project, and navigate to the Views | MySolution.Module.BusinessObjects | Contact_ListView | Columns node to invoke the Grid List Editor Designer. It will display the default structure of the List View. You can customize the default appearance of the List View by dragging, resizing and grouping the columns. Invoke the Customization window by right-clicking the table header and selecting Column Chooser.
-
调用 MySolution.模块项目的模型编辑器,并导航到视图 |My解决方案.模块.业务对象 |Contact_ListView |列节点以调用网格列表编辑器设计器。它将显示列表视图的默认结构。您可以通过拖动、调整大小和分组列来自定义列表视图的默认外观。通过右键单击表标题并选择"列选择器"来调用自定义窗口。
-
For example, customize the List View to display the following columns.
-
例如,自定义列表视图以显示以下列。
- FullName 全名
- Position 位置
- Department 部门
- Email 电子邮件
-
-
Run the WinForms or ASP.NET application. See if the Contact List View looks like the following image.
-
运行 WinForms 或ASP.NET应用程序。查看联系人列表视图是否类似于下图。
-
-
Tip 提示
When the browser window shrinks, some columns become hidden and can be accessed using the "..." button (see IModelColumnWeb.AdaptivePriority).
当浏览器窗口收缩时,某些列将变为隐藏状态,可以使用"...""按钮进行访问(请参阅 IModelColumnWeb.自适应优先级)。
If you previously customized the visibility of the Contact List View columns at runtime, the new set of visible columns will not be applied. To remove the previous customization in a WinForms application, click the Reset View Settings button. Alternatively, you can invoke the Runtime Model Editor (using the Tools | Edit Model menu item), right-click the Views | Contact_ListView node and select Reset Differences.
如果以前在运行时自定义了联系人列表视图列的可见性,则将不会应用新的可见列集。要删除 WinForms 应用程序中的先前自定义项,请单击"重置视图设置"按钮。或者,您可以调用运行时模型编辑器(使用工具 |编辑模型菜单项),右键单击视图 |Contact_ListView节点并选择"重置差异"。
You can see the changes made in the 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 注意
Alternatively, you can customize column order and visibility by changing the value of the Index property of specific columns (Columns node's child nodes). Refer to the List View Columns Customization article to learn more.
或者,您可以通过更改特定列(列节点的子节点)的 Index 属性的值来自列顺序和可见性。有关详细信息,请参阅列表视图列自定义一文。
Tip 提示
You can arrange columns into logical groups (bands). For details, refer to the List View Bands Layout topic.
您可以将列排列到逻辑组(波段)。有关详细信息,请参阅列表视图波段布局主题。
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客户端