Link to home
Start Free TrialLog in
Avatar of samyee
samyee

asked on

HELP: New line in CEdit

How to insert a new line and other formatting (e.g. tab) in a multi-line CEdit control???

in my code
=====
m_edit = _T("Hello\n World \t Hello");
UpdateDate(FALSE);
========

Garbage char appears instead!!! Pls show me simple sample code as well.... thanks :-)

Another question: I notice when I make the CEdit read-only... the text is all highlighted initially....

How to remove that selection???
ASKER CERTIFIED SOLUTION
Avatar of pagladasu
pagladasu

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of pagladasu
pagladasu

And I forgot earlier about the second part of the question.
If at all you do not want the read-only edit control not to get any focus you can
uncheck the Tabstop property of the control.

Otherwise, if you want it to receive tab focus, then create a control variable, say called m_editctrl of type CEdit. Map the EN_SETFOCUS message of the edit control and insert the following code in the OnSetfocusEdit1():

      m_editctrl.SetSel(0,0);

The proper way to insert a new line into a multi-line edit control is to use:

CString String;
String = "This is one line of the string.\r\nThis is the next line is here.";

\r\n in place of the \n.  To insert a tab, the    \t    should work proplerly.

J.R.


Avatar of samyee

ASKER

Thanks pagladasu!!!

And also to jrmcg who suggest a good method!!!