Ticket E1806
Visible to All Users

How to add custom properties to a DetailView dynamically at runtime

created 24 years ago (modified 6 years ago)

Suppose that it is necessary to provide a capability to work with documents. These documents can have various sets of fields, in various orders. To implement this scenario using standard XAF tools, it is necessary to create a lot of business classes, one for each kind of document. This solution doesn't allow the creation of a new document kind.

Comments (3)

    Does not work in edit mode on v12.1.4

      This example fails on 'New'.    Run, click new button.
      NullReferenceExeption:  Object reference not set to an instance of an object.
      private void CreateLayoutItems(LayoutControl layout) {

                 for (int i = 0; i < itemsPerRow - columnIndex; i++) {
      FAIL  -->              row.Add(new EmptySpaceItem());
                 }

      Anatol (DevExpress) 11 years ago

        I have fixed the problem. Please see the updated example.

        Answers approved by DevExpress Support

        created 6 years ago (modified a year ago)

        You can accomplish this task by embedding a custom control that renders the required editors based on a collection of custom properties:
        How to: Show a Custom Data-Bound Control in an XAF View (Blazor) - Current Object Data
        How to: Show a Custom Data-Bound Control in an XAF View (WinForms)
        How to: Show a Custom Data-Bound Control in an XAF View (ASP.NET)

        Obsolete

        Attached is an example that demonstrates how to implement a custom property editor named DocumentItemsPropertyEditor. It is used to draw a table with editors associated with document items.

        We consider this approach as outdated and advise against using it in a new project. If you used this approach for the long time and found that ASPxLookupPropetyEditor throws NullReferenceException when closing a DetailView, download the modified example attached to this answer and replace the WebDocumentItemsPropertyEditor.cs or WebDocumentItemsPropertyEditor.vb file in your project with the new version.

        See Also:
        How to: Include a Custom UI Control That Is Not Integrated by Default (WinForms, ASP.NET WebForms, and ASP.NET Core Blazor)
        How to create business classes at runtime based on predefined configurations or allow user to define custom members via the application UI

          Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

          Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.