Skip to main content
A newer version of this page is available. .

TextEdit Class

Represents a text editor.

Namespace: DevExpress.Xpf.Editors

Assembly: DevExpress.Xpf.Core.v20.1.dll

NuGet Packages: DevExpress.WindowsDesktop.Wpf.Core, DevExpress.Wpf.Core

Declaration

public class TextEdit :
    TextEditBase,
    ISupportTextHighlighting

Remarks

TextEdit Context Menu

The TextEdit represents a single-line text editor by default. To enable multi-line editing, set the TextEditBase.TextWrapping property to Wrap.

Tip

The TextEdit class inherits its features from the TextEditBase class.

Refer to the TextEditBase class description for information on derived features and API.

Create a TextEdit

To specify the editor’s value, use the BaseEdit.EditValue or TextEditBase.Text property.

<Window ...
    xmlns:dxe="http://schemas.devexpress.com/winfx/2008/xaml/editors">

<!-- Specify value using the TextEditBase.Text property -->
<dxe:TextEdit Text="Hello World!"/>

<!-- Specify value using the BaseEdit.EditValue property -->
<dxe:TextEdit EditValue="Hello World!"/>

To respond to changing the editor’s value, handle the BaseEdit.EditValueChanged event. To check the new value’s validity, handle the BaseEdit.Validate event.

Character Casing

If the CharacterCasing property is set to Upper or Lower, the editor’s new values will be automatically converted to the corresponding case.

Masked Input

The TextEdit allows you to use masks during editing. To learn more, see Masked Input.

Text Selection

Set the SelectAllOnGotFocus property to true to enable automatic text selection when the editor gets focus via the keyboard. To enable text selection when the editor gets focus via mouse click, set the SelectAllOnMouseUp to true.

To select all the text within the editor manually, use the SelectAll method. To select only the specified amount of text, use the TextEdit.Select(System.Int32,System.Int32) method.

When an end user double-clicks a word in a text edit, the focused word is selected. When an end user clicks 3 times, all the editor’s text is selected (that is the same as calling the SelectAll method).

Spin Input

The TextEdit.SpinUp method is in effect if the editor’s TextEdit.MaskType property is set to MaskType.Numeric or MaskType.DateTime.

An end user can increment the editor’s value by scrolling up the mouse wheel or by pressing the UP key. If the editor’s TextEdit.MaskType property is set to MaskType.DateTime, the TextEdit.SpinUp method increments a component of the date where the caret is located.

To decrement the editor’s value, use the TextEdit.SpinDown method. Calling the TextEdit.SpinUp or TextEdit.SpinDown method fires the TextEdit.Spin event.

In-Place TextEdit

To embed a TextEdit into a container control, use the TextEditSettings class.

The following code snippets (auto-collected from DevExpress Examples) contain references to the TextEdit class.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also