Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Obtaining Values in Display and Edit Modes

  • 2 minutes to read
In This Article

#Display Mode

When the editor is not focused, it is in the Display mode.

The BaseEdit.EditValue property contains the editor’s current value as an object whose type can vary widely. The TextEditBase.Text property contains the text representation of the BaseEdit.EditValue property. The BaseEdit.DisplayText property contains the text that is displayed by the editor in Display mode.

See the example below:

<Window x:Class="DisplayMode.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
        Title="MainWindow" Height="350" Width="525" xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors">
    <Grid>
        <dxe:TextEdit HorizontalAlignment="Center" Name="textEdit1" VerticalAlignment="Center" Width="150"  
                      MaskType="Numeric" Mask="c2" MaskUseAsDisplayFormat="True" >
            <dxe:TextEdit.EditValue>
                <sys:Double>100</sys:Double>
            </dxe:TextEdit.EditValue>
        </dxe:TextEdit>
        <Label Height="85" HorizontalAlignment="Center" Name="label1" VerticalAlignment="Bottom" />
    </Grid>
</Window>
using System.Windows;

namespace DisplayMode
{
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            label1.Content = "textEdit1.EditValue = " + textEdit1.EditValue + ";\n" + 
                             "textEdit1.Text = " + textEdit1.Text + ";\n" + 
                             "textEdit1.DisplayText = " + textEdit1.DisplayText;
        }
    }
}

text properties

#Edit Mode

When the editor is focused, it is in the Edit mode. In this mode, the end-user can change the editor’s value manually. The changes made by the end-user are posted to the BaseEdit.EditValue only after the Input Validation succeeds; otherwise, the BaseEdit.EditValue property contains its previous valid value.

The BaseEdit.EditCore property can be used to obtain the text that is displayed by the editor in the Edit mode. For example, to obtain the text that is displayed by the TextEdit in the Edit mode, use the following code:

string editModeText = ((TextBox)textEdit1.EditCore).Text;

Note that, by default, in edit mode, the type of the object returned by the BaseEdit.EditCore property depends on the editor type. This property contains a control specified by the BaseEdit.EditTemplate property. The table below shows the corresponding types of BaseEdit.EditCore property values for specific editor types, by default.

Editor Type BaseEdit.EditCore Type
TextEdit TextBox
ListBoxEdit DevExpress.Xpf.Editors.Popups.EditorListBox
ComboBoxEdit TextBox