Skip to main content

MemoEdit Class

A multi-line text editor.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.XtraEditors.v25.2.dll

NuGet Package: DevExpress.Win.Navigation

Declaration

public class MemoEdit :
    TextEdit,
    IAutoHeightControl,
    IAutoHeightControlEx,
    ISupportScrollBarColorize

Remarks

The MemoEdit control displays and edits multi-line text. Key features include:

  • Word wrap
  • Configurable scrollbars
  • Keyboard input (Enter and Tab)
  • Automatic height

The following screenshots demonstrate MemoEdit controls that are used standalone and embedded within a container control:

WinForms MemoEdit, DevExpress

Run Demo: Memo Edit

Edit Value

Use the Text or EditValue property to get or set the memo content.

memoEdit.Text = "Line 1\r\nLine 2\r\nLine 3";

Use the Lines property to obtain an array of strings, where each element is a line separated by \r\n. Use the AppendLine(String) method to append a new line.

Word Wrap

The MemoEdit wraps long text. Set the WordWrap property to false to disable this behavior. When word wrap is disabled, text wraps only at explicit \r\n line breaks.

memoEdit.Properties.WordWrap = false;
memoEdit.Text = "Column A\tColumn B\tColumn C";

Scrollbars

Use the ScrollBars property to control the visibility of horizontal and vertical scrollbars in the MemoEdit control.

memoEdit.Properties.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;

Handle Enter and Tab Keys

Use the following properties to configure keyboard behavior:

Property Description
AcceptsReturn Gets or sets a value specifying whether return characters can be inserted into text.
AcceptsTab Gets or sets a value specifying whether a user can insert tab characters into text.

Auto Height

The CalcAutoHeight() method calculates the height required to display the control’s entire content.

The following code snippet resizes a MemoEdit control to fit its content when the text changes:

private void memoEdit1_TextChanged(object sender, EventArgs e) {
    MemoEdit memo = (MemoEdit)sender;
    memo.Height = memo.CalcAutoHeight();
}

When the MemoEdit control is used within a LayoutControl, use the LayoutControlAutoHeightMode property to specify its automatic height behavior.

Use MemoEdit in a Container Control

The following code snippet assigns a RepositoryItemMemoEdit to a Data Grid column:

using System;
using System.Windows.Forms;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraEditors.Repository;

namespace GridMemoEdit {
    public partial class Form1 : RibbonForm {
        RepositoryItemMemoEdit riMemoEdit;
        public Form1() {
            InitializeComponent();
            gridControl.ForceInitialize();
            riMemoEdit = new RepositoryItemMemoEdit() {
                AcceptsTab = true,
                AcceptsReturn = true,
                LinesCount = 5
            };
            gridControl.RepositoryItems.Add(riMemoEdit);
            gridView.Columns["Notes"].ColumnEdit = riMemoEdit;
            gridView.OptionsView.RowAutoHeight = true;
        }

        private void Form1_Load(object sender, EventArgs e) {
            this.employeesTableAdapter.Fill(this.nwindDataSet1.Employees);
        }
    }
}

Tip

Advanced Mode

Enable the MemoEdit.Properties.UseAdvancedMode property to activate the following features:

  • Animated caret and selection
  • Text highlighting
  • Floating labels
  • Emoji support (Win+.)

Text Highlighting - WinForms MemoEdit, DevExpress

Run Demo: Memo Edit View Example

Use MemoExEdit if you need a MemoEdit with a drop-down window.

Inheritance

See Also