Numeric Properties
- 6 minutes to read
XAF supports Property Editors for numeric data types (byte
, int
, decimal
, long
, corresponding nullable types, etc.) on all platforms. However, WinForms, ASP.NET Web Forms, and Blazor UI applications use different formatting rules depending on the underlying property type.
Refer to the following topics for information on how to add Numeric properties to business classes in the supported ORM systems:
ASP.NET Core Blazor
In ASP.NET Core Blazor, BlazorPropertyEditorBase.ComponentModel returns an IComponentModel
descendant that wraps properties and events of a corresponding ASP.NET Core Blazor Editor.
NumericPropertyEditor
IComponentContentHolder descendant: DevExpress.ExpressApp.Blazor.Editors.Adapters.DxSpinEditAdapter<T>
.
Component: the DxSpinEdit<T> editor shipped with the DevExpress ASP.NET Core Blazor Library.
Description:
This is the default Property Editor for the following numeric property types: Int16
, UInt16
, Int32
, UInt32
, Int64
, UInt64
, float
, double
, Decimal
, byte
.
To access and customize UI controls in XAF applications, create a ViewController that accesses a NumericPropertyEditor
object to modify the underlying DxSpinEdit<T> control. For more information, refer to the following topic: Access the Settings of a Property Editor in a Detail View.
Disable Mouse Wheel Functionality
Users can scroll the mouse wheel to change the NumericPropertyEditor
‘s value. To disable this behavior, ensure that the DxSpinEdit.AllowMouseWheel property is set to false
.
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Blazor.Editors;
using DevExpress.ExpressApp.Blazor.Editors.Adapters;
public class CustomizeNumericPropertyEditorController : ViewController {
protected override void OnActivated() {
base.OnActivated();
if(View is ListView { Editor: DxGridListEditor gridListEditor }) {
gridListEditor.CustomizeViewItemControl<NumericPropertyEditor>(this, CustomizePropertyEditor);
}
else if(View is DetailView detailView) {
detailView.CustomizeViewItemControl<NumericPropertyEditor>(this, CustomizePropertyEditor);
}
}
private void CustomizePropertyEditor(NumericPropertyEditor numericPropertyEditor) {
numericPropertyEditor.ComponentModel.AllowMouseWheel = false;
}
}
Hide Spin Buttons
A NumericPropertyEditor
displays spin buttons that allow users to change the editor’s value. To hide these buttons, ensure that the DxSpinEdit.ShowSpinButtons property is set to false
.
using DevExpress.ExpressApp;
using DevExpress.ExpressApp.Blazor.Editors;
using DevExpress.ExpressApp.Blazor.Editors.Adapters;
public class CustomizeNumericPropertyEditorController : ViewController {
protected override void OnActivated() {
base.OnActivated();
if(View is ListView { Editor: DxGridListEditor gridListEditor }) {
gridListEditor.CustomizeViewItemControl<NumericPropertyEditor>(this, CustomizePropertyEditor);
}
else if(View is DetailView detailView) {
detailView.CustomizeViewItemControl<NumericPropertyEditor>(this, CustomizePropertyEditor);
}
}
private void CustomizePropertyEditor(NumericPropertyEditor numericPropertyEditor) {
numericPropertyEditor.ComponentModel.ShowSpinButtons = false;
}
}
Apply Numeric Mask
To apply a mask to a NumericPropertyEditor
, use the EditMask property and the Numeric mask type syntax.
To further customize the mask, access the NumericPropertyEditor.MaskProperties
property.
For an example, refer to the following topic: Access EditMask In Code.
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)
BytePropertyEditor
Control: IntegerEdit
– a descendant of the SpinEdit editor shipped with the XtraEditors Library.
Repository Item: RepositoryItemIntegerEdit
– a descendant of the XtraEditors Library’s RepositoryItemSpinEdit item.
Description:
This is the default Property Editor for byte
properties.
The editor is a descendant of the IntegerPropertyEditor
class. If the repository item’s MaxValue
property is set to 0
or to a value that exceeds Byte.MaxValue
, the property value is reset to Byte.MaxValue
. If the repository item’s MinValue
property is set to 0
or to a value that is less than Byte.MinValue
, the property value is reset to Byte.MinValue
.
DecimalPropertyEditor
Control: DecimalEdit
– a descendant of the SingleEdit
editor used by the FloatPropertyEditor
.
Repository Item: RepositoryItemDecimalEdit
– a RepositoryItemSingleEdit
item descendant used by the FloatPropertyEditor
.
Description:
This is the default Property Editor for decimal
properties.
The RepositoryItemSingleEdit
class helps to store and display values using the C
Numeric edit mask when the Property Editor’s EditMask
is not specified.
DoublePropertyEditor
Control: DoubleEdit
– a SingleEdit
editor descendant used by the FloatPropertyEditor
.
Repository Item: RepositoryItemDoubleEdit
– a RepositoryItemSingleEdit
item descendant used by the FloatPropertyEditor
.
Description:
This is the default Property Editor for double
properties.
FloatPropertyEditor
Control: SingleEdit
– an IntegerEdit
editor descendant used by the IntegerPropertyEditor
.
Repository Item: RepositoryItemSingleEdit
– a RepositoryItemIntegerEdit
item descendant used by the IntegerPropertyEditor
.
Description:
This is the default Property Editor for float
properties.
The RepositoryItemIntegerEdit
class allows you to display float values.
IntegerPropertyEditor
Control: IntegerEdit
– a descendant of the SpinEdit editor shipped with the XtraEditors Library.
Repository Item: RepositoryItemIntegerEdit
– a descendant of the XtraEditors Library’s RepositoryItemSpinEdit item.
Description:
This is the default Property Editor for Int32
properties.
An IntegerPropertyEditor
object has the EditMask
property. This property’s default value is the Views | <DetailView> | Items | <PropertyEditor> node’s IModelCommonMemberViewItem.EditMask property value. When you assign a value to this property or to the EditMask
attribute directly in code, use the syntax of the Numeric mask type. In this instance, the specified mask is applied to the property value displayed by the Property Editor. Refer to the following topic for more information: Mask Editors Overview | Mask Types.
LongPropertyEditor
Control: IntegerEdit
– a descendant of the SpinEdit editor shipped with the XtraEditors Library.
Repository Item: RepositoryItemIntegerEdit
– a descendant of the XtraEditors Library’s RepositoryItemSpinEdit item.
Description:
This is the default Property Editor for Int64
properties.
The editor is an IntegerPropertyEditor
class descendant. If the repository item’s MaxValue
property is set to 0
or to a value that exceeds Long.MaxValue
, the property value is reset to Long.MaxValue
. If the repository item’s MinValue
property is set to 0
or to a value that is less than Long.MinValue
, the property value is reset to Long.MinValue
.
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.
ASPxBytePropertyEditor
View mode control: Label.
Edit mode control: the ASPxSpinEdit editor from the ASPxEditors Library.
Description:
This is the default Property Editor for byte
properties.
ASPxDecimalPropertyEditor
View mode control: Label.
Edit mode control: the ASPxSpinEdit editor from the ASPxEditors Library.
Description:
This is the default Property Editor for decimal
properties. The editor is inherited from the ASPxIntPropertyEditor
class.
Uses the C
edit mask and display format. This Property Editor also enables float value input.
ASPxDoublePropertyEditor
View mode control: Label.
Edit mode control: the ASPxSpinEdit editor from the ASPxEditors Library.
Description:
This is the default Property Editor for double
properties. The editor is inherited from the ASPxFloatPropertyEditor
class. Casts the editor’s value to the double type.
ASPxFloatPropertyEditor
View mode control: Label.
Edit mode control: the ASPxSpinEdit editor from the ASPxEditors Library.
Description:
This is the default Property Editor for single
properties.
The editor is inherited from the ASPxIntPropertyEditor
class. Uses the F
edit mask and display format. This Property Editor also enables float value input.
ASPxIntPropertyEditor
View mode control: Label.
Edit mode control: the ASPxSpinEdit editor from the ASPxEditors Library.
Description:
This is the default Property Editor for Int32
properties.
ASPxInt64PropertyEditor
View mode control: Label.
Edit mode control: the ASPxSpinEdit editor from the ASPxEditors Library.
Description:
This is the default Property Editor for Int64
properties. The editor is inherited from the ASPxIntPropertyEditor
class. Casts the editor’s value to the Int64
type.