CEdit
lastmod 2021-02-25created 2016-11-164 edits
The CEdit class provides the functionality of a Windows edit control. An edit control is a rectangular child window in which the user can enter text.
Basic usage
Get the string in a CEdit.
Get the length of the string in a CEdit.
Enter a string into a CEdit.
Scroll automatically when entering a string into a CEdit.
Clear all contents of a CEdit.
Total number of lines of the string in a CEdit.
Number of characters in a line.
Get the index of the first character of a given line.
Add characters at the very beginning of the CEdit box.
Set the string capacity of a CEdit. //(can be set up to 65536)//
Set read-only.
How to scroll automatically
To scroll automatically to the last line in a multiline edit control, do the following.
Text Get/Set
DDX Example
When using DDX, it can be used as follows.
void CLiveDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
// ...
DDX_Control(pDX, IDC_EDIT_LOG, m_edit2);
}
// ...
UpdateData();
m_edit2 = m_edit1;
UpdateData(FALSE);
Troubleshooting
Solutions to problems when using the CEdit class
- If the 'Enter Key' cannot be entered when the multiline (ES_MULTILINE) property is set, add ES_WANTRETURN to the style information.
See also
Favorite site
- MSDN: CEdit class
- [http://msdn.microsoft.com/en-us/library/f7yhsd2b(v=vs.71.aspx MSDN CEdit Class]
- [http://msdn.microsoft.com/ko-kr/library/bb775464(v=vs.80.aspx MSDN Edit Control Styles list]
- Using CEdit in MFC
- Using CEdit in MFC