This topic demonstrates how to access editors in a Detail View using a View Controller. This Controller searches the Contact Detail View for an Anniversary Property Editor that binds data to a control, and specifies that the control displays "N/A" when the Anniversary property value is not set. The "N/A" text is shown when the Detail View is in the Edit Mode (DetailView.ViewEditMode).

本主题演示如何使用视图控制器访问详细信息视图中的编辑器。此控制器搜索联系人详细信息视图以寻找将数据绑定到控件的周年属性编辑器,并指定控件在未设置周年属性值时显示"N/A"。当详细视图处于编辑模式(详细信息视图.ViewEdit 模式)时,将显示"N/A"文本。

Note 注意

We recommend reviewing the following topics before proceeding:

我们建议在继续之前查看以下主题:

  • Inherit from the Business Class Library Class (XPO/EF)
  • Add a Simple Action
  • 从商务舱库类 (XPO/EF) 继承
  • 添加简单操作

To see the example discussed in this topic, access the MainDemo.Module.Win | Controllers or MainDemo.Module.Web | Controllers folder and open the WinNullTextEditorController.cs (WinNullTextEditorController.vb) or WebNullTextEditorController.cs (WebNullTextEditorController.vb) file. 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/

.要查看本主题中讨论的示例,请访问 MainDemo.module.Win |控制器或主模块.Web |控制器文件夹并打开WinNullTextEditorController.cs(WinNullText编辑器控制器.vb)或WebNullTextEditorController.cs(WebNullText编辑器控制器.vb)文件。主演示应用程序安装在%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/

Access Editor Settings in a WinForms Application

访问 WinForms 应用程序中的编辑器设置

  • Add a View Controller called "WinNullTextEditorController" to the MySolution.Module.Win project as described in the Add a Simple Action lesson (steps 1-3). Make sure you set the TargetViewType property to DetailView (step 3).

  • Override the OnActivated method. Use the CompositeView.FindItem method to get the Anniversary Property Editor from the current View's CompositeView.Items list which contains Property Editors and View Items.

  • In the OnActivated method, subscribe to the CompositeView.ItemsChanged event. Then, the Controller processes the Anniversary View Item that a user added at runtime. Otherwise, the Controller works only with the item included in the Detail View at design time.
  • Use the ViewItem.Control property to access the Anniversary Property Editor's control. Cast the control to the appropriate type to use its properties or subscribe to its events. See Data Types Supported by built-in Editors to determine the valid control type for a Property Editor. In the example below, the ViewItem.Control value is cast to the BaseEdit type.
  • Subscribe to the ViewItem.ControlCreated event and place your customization code in its handler to prohibit the control customization until the control is created.
  • 将名为"WinNullText编辑器控制器"的视图控制器添加到 MySolution.module.win 项目,如添加简单操作课(步骤 1-3)中所述。请确保将"目标视图"属性设置为"详细信息视图"(步骤 3)。
  • 覆盖 On 已激活的方法。使用"复合视图.FindItem"方法从当前视图的"复合视图"中获取周年属性编辑器。项目列表包含属性编辑器和视图项。
  • 在 On 已激活方法中,订阅复合视图.Items 更改事件。然后,控制器处理用户在运行时添加的周年视图项目。否则,控制器仅在设计时使用"详细信息视图"中包含的项目。
  • 使用 ViewItem.Control 属性访问周年属性编辑器的控件。将控件强制转换为适当的类型以使用其属性或订阅其事件。请参阅内置编辑器支持的数据类型,以确定属性编辑器的有效控件类型。在下面的示例中,ViewItem.Control 值将转换为 BaseEdit 类型。
  • 订阅 ViewItem.Control 创建事件,并将自定义代码放在其处理程序中,以禁止控件自定义,直到创建控件。

The following code demonstrates the WinNullTextEditorController:

以下代码演示了 WinNullText 编辑器控制器:

using DevExpress.XtraEditors;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Editors;
using DevExpress.ExpressApp.Utils;
// ...
public partial class WinNullTextEditorController : ViewController {
public WinNullTextEditorController() {
InitializeComponent();
RegisterActions(components);
}
private void InitNullText(PropertyEditor propertyEditor) {
((BaseEdit)propertyEditor.Control).Properties.NullText = CaptionHelper.NullValueText;
}
private void WinNullTextEditorController_ItemsChanged(Object sender, ViewItemsChangedEventArgs e) {
if(e.ChangedType == ViewItemsChangedType.Added && e.Item.Id == "Anniversary") {
TryInitializeAnniversaryItem();
}
}
private void propertyEditor_ControlCreated(Object sender, EventArgs e) {
InitNullText((PropertyEditor)sender);
}
protected override void OnActivated() {
base.OnActivated();
((CompositeView)View).ItemsChanged += WinNullTextEditorController_ItemsChanged;
TryInitializeAnniversaryItem();
}
protected override void OnDeactivated() {
base.OnDeactivated();
((CompositeView)View).ItemsChanged -= WinNullTextEditorController_ItemsChanged;
}
public void TryInitializeAnniversaryItem() {
PropertyEditor propertyEditor = ((DetailView)View).FindItem("Anniversary") as PropertyEditor;
if(propertyEditor != null) {
if(propertyEditor.Control != null) {
InitNullText(propertyEditor);
}
else {
propertyEditor.ControlCreated += new EventHandler<EventArgs>(propertyEditor_ControlCreated);
}
}
}
}

Note that the WinNullTextEditorController uses the CaptionHelper.NullValueText property to get a localized "N/A" text.

Run the WinForms application and open the Contact Detail View. The Anniversary editor shows the "N/A" text if the editor's value is unspecified.

请注意,WinNullText编辑器控制器使用标题帮助器.NullValueText属性获取本地化的"不适用"文本。
运行 WinForms 应用程序并打开"联系人详细信息"视图。如果未指定编辑器的值,则周年编辑器将显示"不适用"文本。

Tip 提示

This approach is not applicable to List View's in-place editors. To customize these editors, do one of the following:

  • Use a custom property editor as shown in the How to: Customize a Built-in Property Editor (WinForms) topic.
  • Access the List Editor control's events and properties as described in the Access Grid Control Properties article.

此方法不适用于列表视图的就地编辑器。要自定义这些编辑器,请执行以下操作之一:

  • 使用自定义属性编辑器,如"如何:自定义内置属性编辑器 (WinForms)"主题中所示。
  • 访问列表编辑器控件的事件和属性,如访问网格控制属性一文中所述。

Access Editor Settings in an ASP.NET Application

访问ASP.NET应用程序中的编辑器设置

  • Add a View Controller called "WebNullTextEditorController" to the MySolution.Module.Web project as described in the Add a Simple Action topic (steps 1-3).
  • Override the OnActivated method. Use the CompositeView.FindItem method to get the Anniversary Property Editor from the current View's CompositeView.Items list. It contains Property Editors and View Items.
  • Use the WebPropertyEditor.Editor property to access the Anniversary Property Editor's control. Cast the control to the appropriate type to use its properties or subscribe to its events. See Data Types Supported by built-in Editors to determine the valid control type for a Property Editor. In the example below, the ViewItem.Control value is cast to the ASPxDateEdit type.
  • Subscribe to the ViewItem.ControlCreated event to ensure that the control was created before you customize it.
  • 将名为"WebNullText编辑器控制器"的视图控制器添加到 MySolution.module.Web 项目中,如"添加简单操作"主题(步骤 1-3)中所述。
  • 覆盖 On 已激活的方法。使用"复合视图.FindItem"方法从当前视图的"复合视图.项目"列表中获取周年属性编辑器。它包含属性编辑器和视图项。
  • 使用 WebPropertyEditor.Editor 属性访问周年属性编辑器的控件。将控件强制转换为适当的类型以使用其属性或订阅其事件。请参阅内置编辑器支持的数据类型,以确定属性编辑器的有效控件类型。在下面的示例中,ViewItem.Control 值强制转换为 ASPxDateEdit 类型。
  • 订阅 ViewItem.Control 创建事件,以确保在自定义控件之前已创建该控件。

The following code demonstrates the WebNullTextEditorController:

以下代码演示了 WebNullText编辑器控制器:

using DevExpress.Web;
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Web.Editors;
using DevExpress.ExpressApp.Utils;
using DevExpress.ExpressApp.Editors;
// ...
public partial class WebNullTextEditorController : ViewController {
public WebNullTextEditorController() {
InitializeComponent();
RegisterActions(components);
}
private void InitNullText(WebPropertyEditor propertyEditor) {
if(propertyEditor.ViewEditMode == DevExpress.ExpressApp.Editors.ViewEditMode.Edit) {
((ASPxDateEdit)propertyEditor.Editor).NullText = CaptionHelper.NullValueText;
}
}
private void propertyEditor_ControlCreated(object sender, EventArgs e) {
InitNullText((WebPropertyEditor)sender);
}
protected override void OnActivated() {
base.OnActivated();
WebPropertyEditor propertyEditor = ((DetailView)View).FindItem("Anniversary") as WebPropertyEditor;
if(propertyEditor != null) {
if(propertyEditor.Control != null) {
InitNullText(propertyEditor);
}
else {
propertyEditor.ControlCreated += new EventHandler<EventArgs>(propertyEditor_ControlCreated);
}
}
}
protected override void OnDeactivated() {
base.OnDeactivated();
ViewItem propertyEditor = ((DetailView)View).FindItem("Anniversary");
if(propertyEditor != null) {
propertyEditor.ControlCreated -= new EventHandler<EventArgs>(propertyEditor_ControlCreated);
}
}
}

Note that the WebNullTextEditorController uses the CaptionHelper.NullValueText property to get a localized "N/A" text.

Run the ASP.NET application and open the Contact Detail View. The Anniversary editor shows the "N/A" text if the editor's value is unspecified.

请注意,WebNullText编辑器控制器使用标题帮助器.NullValueText属性获取本地化的"不适用"文本。

运行ASP.NET应用程序并打开"联系人详细信息"视图。如果未指定编辑器的值,则周年编辑器将显示"不适用"文本。

Tip 提示

This approach does not affect List View's in-place editors. To customize these editors as well, use the solution described in the How to: Customize a Built-in Property Editor (ASP.NET) topic. Alternatively, access the required in-place Web List Editor as directed in the ComplexWebListEditor.FindPropertyEditor method description. To apply custom settings to an ASPxGridListEditor's column, handle the ASPxGridListEditor.CreateCustomGridViewDataColumn and ASPxGridListEditor.CustomizeGridViewDataColumn events. If you need to access a template for displaying cells within the current column, use the ASPxGridListEditor.CreateCustomDataItemTemplate and ASPxGridListEditor.CreateCustomEditItemTemplate events.

此方法不会影响列表视图的就地编辑器。要自定义这些编辑器,请使用"如何:自定义内置属性编辑器 (ASP.NET)"主题中介绍的解决方案。或者,按照复杂WebListEditor.FindPropertyEditor方法说明中的指示,访问所需的就地Web列表编辑器。要将自定义设置应用于 ASPxGridlist 编辑器的列,请处理 ASPxGridlistEditor.创建自定义网格视图数据列和 ASPxGridlistEditor.自定义网格视图数据列事件。如果需要访问用于显示当前列中的单元格的模板,请使用 ASPxGridListEditor.创建自定义数据项目模板和 ASPxGridListEditor.创建自定义编辑项目模板事件。

Due to WinForms and ASP.NET platform specifics, View Item and List Editor controls may not be immediately ready for customization after the control is created. Consider handling additional platform-dependent events or using alternative approaches if the customizations above do not have any effect.

由于 WinForms 和ASP.NET平台细节,在创建控件后,视图项和列表编辑器控件可能不会立即准备好进行自定义。如果上述自定义项没有任何效果,请考虑处理其他与平台相关的事件或使用替代方法。

  • WinForms:

    Handle the System.Windows.Forms.Control

object's HandleCreated, VisibleChanged or ParentChanged

  • WinForms:
    处理系统.Windows.窗体.控件

    对象的句柄已创建、可见更改或父更改

  • events. You can also handle the Load (or similar) event if the current control type exposes it.

  • 事件。如果当前控件类型公开了"加载"(或类似)事件,也可以处理该事件。
  • ASP.NET:

    Handle the System.Web.UI.Control

object's Load or Init

  • ASP.NET:

    处理系统.Web.UI.控件

    对象的加载或 Init

  • server-side event. In certain cases, you may need to handle the WebWindow.PagePreRender event. Use the WebWindow.CurrentRequestWindowstatic property to get the current WebWindow object. You can also perform certain customizations on the client side using JavaScript (see Client-Side Functionality Overview).
  • 服务器端事件。在某些情况下,您可能需要处理 WebWindow.pageprein 事件。使用 WebWindow.CurrentRequest 窗口静态属性获取当前 WebWindow 对象。您还可以使用 JavaScript 在客户端执行某些自定义(请参阅客户端功能概述)。

These additional platform-dependent events indicate the controls' "ready" state: a control has been added to the form controls hierarchy or has been bound to data. Contact us using the Support Center

if you need additional help to perform customizations.

这些与平台相关的其他事件指示控件的"就绪"状态:控件已添加到窗体控件层次结构中或已绑定到数据。使用支持中心联系我们如果您需要其他帮助来执行自定义。

Access Editor Settings 访问编辑器设置的更多相关文章

  1. 此项目的默认Web访问模式设置为文件共享, 但是无法从路径(此为转贴)

    故障现象: 当你打开ASP.NET Web项目时,如果出现这样的错误提示:提示窗口标题: Web访问失败提示内容: 此项目的默认Web访问模式设置为文件共享, 但是无法从路径“...”打开“...”处 ...

  2. 【前端】ACE Editor(代码编辑器) 简易使用示例

    身为一个早已退役的Oier,当然忘不了当年一个个OJ页面上的代码显示和代码编辑器. 其中,洛谷使用的ACE Editor就是之一,非常的简洁美观.以及实际上在前端页面上搭建一个ACE Editor也是 ...

  3. SoapUI 访问代理设置

    SoapUI 访问代理设置 by:授客 QQ:1033553122 问题描述: 运行SoapUI时,发现接口访问不通,如下图,提示"Connection to http://127.0.0. ...

  4. loadrunner 运行脚本-Run-time Settings之Preferences设置

    运行脚本-Run-time Settings之Preferences设置 by:授客 QQ:1033553122 打开Preferences设置对话框,这里提供了对运行时的参数选择设置 Enable ...

  5. ACE Editor在线代码编辑器简介及使用引导

    转自博客:https://www.cnblogs.com/cz-xjw/p/6476179.html ACE 是一个开源的.独立的.基于浏览器的代码编辑器,可以嵌入到任何web页面或JavaScrip ...

  6. 【Azure 存储服务】代码版 Azure Storage Blob 生成 SAS (Shared Access Signature: 共享访问签名)

    问题描述 在使用Azure存储服务,为了有效的保护Storage的Access Keys.可以使用另一种授权方式访问资源(Shared Access Signature: 共享访问签名), 它的好处可 ...

  7. Asp.Net Core 使用Monaco Editor 实现代码编辑器

    在项目中经常有代码在线编辑的需求,比如修改基于Xml的配置文件,编辑Json格式的测试数据等.我们可以使用微软开源的在线代码编辑器Monaco Editor实现这些功能.Monaco Editor是著 ...

  8. angularjs中的页面访问权限设置

    11月在赶一个项目,这阵子比较忙,挤挤时间更一篇博客吧,如标题所述说说在ng中页面访问权限控制的问题,水平有限各位看官见谅: 在以往的项目中,前后端常见的配合方式是前端提供页面和ui加一点DuangD ...

  9. 跨域访问-需要设置HTTP响应标头设置

    跨域访问-需要设置HTTP响应标头设置 前提:服务端网站的配置(被请求的网站) 1.需要在IIS服务器站点的功能视图中设置HTTP响应标头: 2.双击“HTTP响应标头”进入设置界面 3.点击右侧添加 ...

随机推荐

  1. Java基础语法09-面向对象下-内部类

    九.内部类 将一个类A定义在另一个类B里面,里面的那个类A就称为内部类,B则称为外部类. (1)成员内部类:声明在外部类中方法外 静态成员内部类 非静态成员内部类 (2)局部内部类:声明在外部类的方法 ...

  2. 记录一次Windows简单构建Dockerfile

    参考文档[https://www.cnblogs.com/GraceSkyer/p/9908984.html] 1]环境说明 操作系统 :win10  ,docker软件:Docker for Win ...

  3. HA: ISRO Vulnhub Walkthrough

    下载地址: https://www.vulnhub.com/entry/ha-isro,376/ 主机扫描: ╰─ nmap -p- -sV -oA scan 10.10.202.131Startin ...

  4. 我也开源... React Native Messager

    近期有空,玩转React Native. https://github.com/andyc365/ReactNativeMessager React Native Messager A React N ...

  5. Dynamics 365中的Client API form context (formContext)

    适用于Dynamics 365 for Customer Engagement apps 9.x版本. 本文是一篇翻译,原文来源是微软官方文档. 本文链接:https://www.cnblogs.co ...

  6. 《老师说的都对》- Alpha冲刺阶段博客目录

    项目小组:<老师说的都对> 项目成员:孙浩杰,谭明耀,宋自康,孙肖肖,王明鑫,王观山 Github仓库地址-PCES 一.Scrum Meeting 第六周会议记录 第七周会议记录 二.测 ...

  7. Kali_Linux 中文乱码 修改更新源及更新问题

    Kali_Linux 中文乱码 修改更新源及更新问题 中文乱码问题 kali默认没有中文字符 当以中文安装或者切换编码换为中文后会出现乱码的情况 解决方法: 确定locales已经安装好, 使用 ap ...

  8. zuul网关

    Zuul路由网关简介及基本使用 简介 Zuul API路由网关服务简介 请看上图,这里的API 路由网关服务 由Zuul实现,主要就是对外提供服务接口的时候,起到了请求的路由和过滤作用,也因此能够隐藏 ...

  9. js解决客户端与服务器时间不一致的问题

    引出 最近在写一个项目时,要根据时间进行不同的展示,直接用new Date().getTime()获取当前时间,结果就出问题了.有些用户擅自修改自己的本地时间,导致获取到的时间并不是当前时间,尴尬. ...

  10. Node.js / Python 日志

    一.Node.js 日志 1.原生 Node.js 原生方法其实很简单,就四个: // 输出到 stdout console.log() console.info() = console.log() ...