MemoEdit Class
A multi-line text editor.
Namespace: DevExpress.XtraEditors
Assembly: DevExpress.XtraEditors.v24.2.dll
NuGet Package: DevExpress.Win.Navigation
#Declaration
public class MemoEdit :
TextEdit,
IAutoHeightControl,
IAutoHeightControlEx,
ISupportScrollBarColorize
#Remarks
Use the MemoEdit
control to display and edit multi-line text. The MemoEdit can be used as a standalone editor or embedded in a container control (for example, Data Grid, TreeList, etc.).
#Edit Value (Text)
Use the MemoEdit.Text
or MemoEdit.EditValue
property to specify the edit value:
string memoText = "The DevExpress WinForms Subscription ships with a comprehensive suite of award-winning Microsoft Office-inspired user interface components. From our blazing fast WinForms Data Grid and Pivot Grid to our Excel-inspired Spreadsheet and Word-inspired Rich Text Editor for Windows Forms, the DevExpress WinForms subscription has everything you'll need to create apps that meet and exceed end-user expectations.";
memoEdit1.Text = memoText;
#Word Wrap
The MemoEdit automatically wraps long text. Set the MemoEdit.Properties.WordWrap property to false to disable this feature. When word wrapping is disabled, the MemoEdit splits the text at each \r\n
escape character.
string memoText = "The DevExpress WinForms Subscription ships with\r\na comprehensive suite of award-winning\r\nMicrosoft Office-inspired user interface\r\ncomponents.";
memoEdit1.Properties.WordWrap = false;
memoEdit1.Text = memoText;
Tip
Use the Memo\r\n
characters.
string[] memoList = new string[] {
"Line 1",
"Line 2",
"Line 3"
};
memoEdit1.Lines = memoList;
string line2 = memoEdit1.Lines[1];
#Scrollbar
Use the MemoEdit.Properties.ScrollBars property to display horizontal, vertical, or both horizontal and vertical scrollbars. The MemoEdit automatically enables or disables scrollbars as needed.
#Handle Enter and Tab Keys
Use the following properties to specify how the MemoEdit handles Enter and Tab key presses:
- MemoEdit.Properties.AcceptsReturn
- If enabled, pressing Enter starts a new line. If disabled, Enter key presses are handled by the form.
- MemoEdit.Properties.AcceptsTab
- Specifies whether the Tab key inserts a tab character in the editor or moves focus to the next UI control on the form.
#Use the MemoEdit in a Container Control
The following code snippet uses the RepositoryItemMemoEdit to display and edit long text in the WinForms Data Grid control (the Data Grid control was created and customized at design time).
Tip
- Enable the grid’s Row
Auto option to automatically adjust row heights based on cell content.Height - Use the Memo
Edit. property to specify the maximum height of the MemoProperties. Lines Count Edit (in text lines) when embedded in a container control.
using System;
using System.Windows.Forms;
using DevExpress.XtraBars.Ribbon;
using DevExpress.XtraEditors.Repository;
namespace GridFindPanel {
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 line of code loads data into the 'nwindDataSet1.Employees' table.
this.employeesTableAdapter.Fill(this.nwindDataSet1.Employees);
}
}
}