Access Editor Settings 访问编辑器设置
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 访问编辑器设置的更多相关文章
- 此项目的默认Web访问模式设置为文件共享, 但是无法从路径(此为转贴)
故障现象: 当你打开ASP.NET Web项目时,如果出现这样的错误提示:提示窗口标题: Web访问失败提示内容: 此项目的默认Web访问模式设置为文件共享, 但是无法从路径“...”打开“...”处 ...
- 【前端】ACE Editor(代码编辑器) 简易使用示例
身为一个早已退役的Oier,当然忘不了当年一个个OJ页面上的代码显示和代码编辑器. 其中,洛谷使用的ACE Editor就是之一,非常的简洁美观.以及实际上在前端页面上搭建一个ACE Editor也是 ...
- SoapUI 访问代理设置
SoapUI 访问代理设置 by:授客 QQ:1033553122 问题描述: 运行SoapUI时,发现接口访问不通,如下图,提示"Connection to http://127.0.0. ...
- loadrunner 运行脚本-Run-time Settings之Preferences设置
运行脚本-Run-time Settings之Preferences设置 by:授客 QQ:1033553122 打开Preferences设置对话框,这里提供了对运行时的参数选择设置 Enable ...
- ACE Editor在线代码编辑器简介及使用引导
转自博客:https://www.cnblogs.com/cz-xjw/p/6476179.html ACE 是一个开源的.独立的.基于浏览器的代码编辑器,可以嵌入到任何web页面或JavaScrip ...
- 【Azure 存储服务】代码版 Azure Storage Blob 生成 SAS (Shared Access Signature: 共享访问签名)
问题描述 在使用Azure存储服务,为了有效的保护Storage的Access Keys.可以使用另一种授权方式访问资源(Shared Access Signature: 共享访问签名), 它的好处可 ...
- Asp.Net Core 使用Monaco Editor 实现代码编辑器
在项目中经常有代码在线编辑的需求,比如修改基于Xml的配置文件,编辑Json格式的测试数据等.我们可以使用微软开源的在线代码编辑器Monaco Editor实现这些功能.Monaco Editor是著 ...
- angularjs中的页面访问权限设置
11月在赶一个项目,这阵子比较忙,挤挤时间更一篇博客吧,如标题所述说说在ng中页面访问权限控制的问题,水平有限各位看官见谅: 在以往的项目中,前后端常见的配合方式是前端提供页面和ui加一点DuangD ...
- 跨域访问-需要设置HTTP响应标头设置
跨域访问-需要设置HTTP响应标头设置 前提:服务端网站的配置(被请求的网站) 1.需要在IIS服务器站点的功能视图中设置HTTP响应标头: 2.双击“HTTP响应标头”进入设置界面 3.点击右侧添加 ...
随机推荐
- 《CSAPP》实验二:二进制炸弹
二进制炸弹是第三章<程序的机器级表示>的配套实验,这章主要介绍了x64汇编,包括:操作数的表示方式,数据传送指令,算术和逻辑指令,控制流跳转指令,过程(procedure)的实现与运行时栈 ...
- 自制导纳信号发生器 [原创cnblogs.com/helesheng]
最近正在研制一种通过测量人体导纳,估算体内血液变化率,进而评估心血管系统泵血功能的医疗仪器.为测量人体导纳,我们设计了一套巧妙的激励信号幅度反馈电路,该电路由于涉及商业机密就不在这里讨论了.这里主要分 ...
- python网络编程socket编程(TCP、UDP客户端服务器)
摘录 python核心编程 使用socket()模块函数创建套接字——通信端点 >>> from socket import * >>> tcpSock = soc ...
- python——模块(Module)的概念、使用以及安装第三方模块
一.模块定义 python中,一个.py文件就是一个模块(Module). 使用模块的好处:1.提高了代码的可维护性.我们把函数进行分组,分别放在不同的模块中.2.编写代码不必要从0开始,当一个模块编 ...
- java存储数据到本地txt文件中
java存储数据,方便打印日志等 1.会覆盖以前的数据 try { File writeName = new File("D:\\data.txt"); // 相对路径,如果没有则 ...
- python 虚拟环境安装与卸载
Ubuntu16.04 安装 卸载 pip原创Solarzhou 发布于2019-06-12 21:50:28 阅读数 2001 收藏展开 实验环境Ubuntu16.04:VMware15: 问题描述 ...
- Pikachu-Sql Inject
Pikachu-Sql Inject 在owasp发布的top10排行榜里,注入漏洞一直是危害排名第一的漏洞,其中注入漏洞里面首当其冲的就是数据库注入漏洞. 一个严重的SQL注入漏洞,可能会直接导致一 ...
- Linux修改History历史命令数量
****打开 vim /etc/profile vim /etc/profile 追加配置 # /etc/profile: system-wide .profile file for the B ...
- STM32基本GPIO操作:按键输入(扫描+外部中断)
(涉及专有名词较多,难免解释不到位,若有错误还请指出,谢谢!) 硬件连接图如下: 一.扫描 思路是在main函数中通过死循环来扫描端口电平状态检测,以此判断按键是否按下.实现较为简单. 1.初始化(注 ...
- java8新特性之——lambda表达式的使用
lambda表达式简介 个人理解,lambda表达式就是一种新的语法,没有什么新奇的,简化了开发者的编码,其实底层还是一些常规的代码.Lambda 是一个匿名函数,我们可以把 Lambda 表达式理解 ...