Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Collapse]eXpressApp Framework
 [Expand]Fundamentals
 [Collapse]Getting Started
  [Expand]Basic Tutorial (SimpleProjectManager Application)
  [Collapse]Comprehensive Tutorial (MainDemo Application)
   [Expand]Business Model Design
   [Collapse]Extend Functionality
     Add a Simple Action
     Add a Parametrized Action
     Add an Action that Displays a Pop-up Window
     Add an Action with Option Selection
     Add a Simple Action using an Attribute
     Access Editor Settings
     Access Grid Control Properties
   [Expand]UI Customization
   [Expand]Extra Modules
   [Expand]Security System
  [Expand]XAF Mobile (Beta) Tutorial
 [Expand]Concepts
 [Expand]Design-Time Features
 [Expand]Functional Testing
 [Expand]Deployment
 [Expand]Task-Based Help
  Frequently Asked Questions
 [Expand]API Reference
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Access Editor Settings

In this lesson, you will learn how to access editors in a Detail Form. For this purpose, a new View Controller will be implemented. It will search a Contact Detail View for an unspecified Anniversary editor. Then, it will set the editor value to "N/A" to bring the unspecified Anniversary property to the user's attention.

Note

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

Expanded Access Editor Settings in a WinForms Application

  • Add a View Controller to the MySolution.Module.Win project as described in the Add a Simple Action lesson. Name it "WinNullTextEditorController".
  • Replace the default Controller code with the following code.

    In the code above, the editor associated with the Anniversary property displays "N/A" text when the property value is not set. To get a localized version of the "N/A" text, the CaptionHelper should be used. It retrieves the localized text from the Application Model's Localization | Texts | NullValueText node where you should specify the text for all the required languages.

    To access a detail form editor, get the corresponding Property Editor, which is the object that binds data to the editor. Property Editors are collected in the current View's CompositeView.Items list, together with View Items of other types. To get the required Property Editor, the CompositeView.FindItem method can be used. Also, you can customize all Property Editors of a certain type using the CompositeView.GetItems<T> method. Since you are going to access the settings of the Property Editor's control, you need to make sure that the control has already been created. This is why it is necessary to subscribe to the Property Editor's ControlCreated event. Also, you need to subscribe to the ItemsChanged event, because an Item object can be recreated.

    Note

    In the code above, the ViewItem.Control value is cast to the BaseEdit type. To determine the valid control type for an arbitrary Property Editor, see the Data Types Supported by built-in Editors section.

    These settings are not applied to in-place editors shown in List Views. To apply them to the in-place editors as well, use the solution described in the How to: Customize a Built-in Property Editor (WinForms) topic.

  • Run the WinForms application and open the Contact detail form. If the Anniversary editor value is not set, the "N/A" text is displayed.

You can see the code demonstrated here in the MySolution.Module.Web | Controllers | WinNullTextEditorController.cs (WinNullTextEditorController.vb) file of the Main Demo installed with XAF. By default, the MainDemo application is installed in %PUBLIC%\Documents\DevExpress Demos 17.2\Components\eXpressApp Framework\MainDemo. The ASP.NET version of this demo is available online at http://demos.devexpress.com/XAF/MainDemo/.

Expanded Access Editor Settings in an ASP.NET Application

  • Add a View Controller to the MySolution.Module.Web project as described in the Add a Simple Action lesson. Name it "WebNullTextEditorController".
  • Replace the default Controller code with the following code.

    In the code above, the editor associated with the Anniversary property displays the "N/A" text when the property value is not set. To get a localized version of the "N/A" text, the CaptionHelper should be used. It retrieves the localized text from the Application Model's Localization | Texts | NullValueText node where you should specify the text for all required languages.

    To access a detail form an editor, get the corresponding Property Editor, which is the object that binds data to the editor. Property Editors are collected in the current View's CompositeView.Items list, along with View Items of other types. To get the required Property Editor, the CompositeView.FindItem method can be used. Also, you can customize all Property Editors of a certain type using the CompositeView.GetItems<T> method. Since you are going to access the settings of the Property Editor's control, you need to make sure that the control has already been created. This is why you need to subscribe to the Property Editor's ControlCreated event. To access the Property Editor's control in Edit mode, the WebPropertyEditor.Editor property should be used. In View mode, there is no need to set null text for unspecified properties.

    Note

    In the code above, the WebPropertyEditor.Editor value is cast to the ASPxDateEdit type. To determine the valid control type for an arbitrary Property Editor, see the Data Types Supported by built-in Editors section.

    These settings are not applied to in-place editors shown in List Views. To apply them to the in-place editors as well, use the solution described in the How to: Customize a Built-in Property Editor (ASP.NET) topic, or refer to the ComplexWebListEditor.FindPropertyEditor method description to learn how to access the Property Editor used in the ComplexWebListEditor.

    You can also handle the ASPxGridListEditor.CreateCustomGridViewDataColumn and ASPxGridListEditor.CustomizeGridViewDataColumn events to access an ASPxGridListEditor's column. Use the ASPxGridListEditor.CreateCustomDataItemTemplate and ASPxGridListEditor.CreateCustomEditItemTemplate events to access a template for displaying cells within the current column.

  • Run the ASP.NET application and open the Contact detail form. If the Anniversary editor value is not set, the "N/A" text is displayed in both View and Edit modes.

You can see the code demonstrated here in the MySolution.Module.Web | Controllers | WebNullTextEditorController.cs (WebNullTextEditorController.vb) file of the Main Demo installed with XAF. By default, the MainDemo application is installed in %PUBLIC%\Documents\DevExpress Demos 17.2\Components\eXpressApp Framework\MainDemo. The ASP.NET version of this demo is available online at http://demos.devexpress.com/XAF/MainDemo/.

Note

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

These specialized control events indicate their "ready" state, which technically means that a control is added into the form controls hierarchy or is bound to data. Consider contacting the DevExpress Support if these additional approaches do not help you perform necessary customizations.

 

Next Lesson: Access Grid Control Properties

Expanded See Also

How would you rate this topic?​​​​​​​