Skip to main content
.NET 6.0+

Type Properties

  • 4 minutes to read

In XAF, properties of the System.Type type can be displayed in a combo box editor that lists the available object types in WinForms and ASP.NET Web Forms applications.

Examples

WinForms

XAF Type Properties WinForms

Each Windows Forms Property Editor is available in two forms:

  • A standalone control (displays property value in a Detail View)
  • A repository item (displays property value in a List Editor that supports in-place editing)

TypePropertyEditor

Control: ImageComboBoxEdit editor from the XtraEditors Library.

Repository Item: RepositoryItemImageComboBox item from the XtraEditors Library.

Description:

Used for Type properties by default.

When declaring a Type property that is displayed using the TypePropertyEditor, apply the System.ComponentModel.TypeConverter attribute to it. In the attribute, pass the type of the converter that returns a collection of values representing data types in the Property Editor. For instance, pass a built-in LocalizedClassInfoTypeConverter, which returns Caption property values for the corresponding BOModel | <Class> nodes.

If you do not use the TypeConverter attribute for a type property, a string representation of found types is loaded to the editor’s Items collection.

Use Alt + Down Arrow to expand the TypePropertyEditor‘s drop-down window.

VisibleInReportsTypePropertyEditor

Control: ImageComboBoxEdit editor from the XtraEditors Library.

Repository Item: RepositoryItemImageComboBox item from the XtraEditors Library.

Description:

The editor is inherited from the TypePropertyEditor. Used by the Pivot Chart Module and Reports V2 Module. It lists the types of business classes that have the VisibleInReports property of the Application Model‘s IModelClass node set to true.

ASP.NET Web Forms

XAF Type Properties ASP.NET Web Forms

Each ASP.NET Web Forms Property Editor includes controls that display a property in a Detail View in View and Edit mode.

ASPxTypePropertyEditor

View mode control: System.Web.UI.WebControls.Label.

Edit mode control: ASPxComboBox editor from the ASPxEditors Library.

Description:

Used for Type properties by default.

When declaring a Type property that is displayed using the TypePropertyEditor, apply the System.ComponentModel.TypeConverter attribute to it. In the attribute, pass the type of the converter that returns a collection of values representing data types in the Property Editor. For instance, pass a built-in LocalizedClassInfoTypeConverter. It returns values of the Caption property of the corresponding BOModel | <Class> nodes.

If you do not use the TypeConverter attribute for a type property, a string representation of found types is loaded to the editor’s Items collection.

To expand the editor’s drop-down window, use Alt + Down Arrow.

ASPxVisibleInReportsTypePropertyEditor

View mode control: System.Web.UI.WebControls.Label.

Edit mode control: ASPxComboBox editor from the ASPxEditors Library.

Description:

Inherited from ASPxTypePropertyEditor. Used by the Pivot Chart Module and Reports V2 Module. It lists the types of business classes that have the VisibleInReports property of the Application Model‘s IModelClass node set to true.

Customize the Types List

Type Property Editors use the LocalizedClassInfoTypeConverter type converter to create the list of values displayed in the editor’s combo box. By default, this converter returns persistent types only. To add all registered non-persistent types to this collection, inherit LocalizedClassInfoTypeConverter, modify the AllowAddNonPersistentObjects field value and pass the custom converter to the TypeConverter attribute type.

using DevExpress.Persistent.Base;
// ...
public class MyLocalizedClassInfoTypeConverter : LocalizedClassInfoTypeConverter {
    public MyLocalizedClassInfoTypeConverter() {
        AllowAddNonPersistentObjects = true;
    }
}
[TypeConverter(typeof(MyLocalizedClassInfoTypeConverter))]
public Type DataType { get; set;}

Override the AddCustomItems method in your custom converter to add specific types to the collection.

public override void AddCustomItems(List<Type> list) {
   list.Add(typeof(MyType));
   list.Sort(this);
   base.AddCustomItems(list);
}

Override the GetSourceCollection method to create the entire collection manually.

public override List<Type> GetSourceCollection(ITypeDescriptorContext context) {
    List<Type> result = new List<Type>();
    // Populate the 'result' list here...
    return result;
}

Tip

More customization approaches are provided in the How to hide or filter out certain types from the drop-down editor for the System.Type properties knowledge base article.