Solved

HELP: New line in CEdit

Posted on 1998-10-21
4
331 Views
Last Modified: 2013-11-20
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???
0
Comment
Question by:samyee
  • 2
4 Comments
 
LVL 4

Accepted Solution

by:
pagladasu earned 50 total points
Comment Utility
Hello there,
You may try out this:
Make sure that the Multiline and Auto VScroll properties of the edit control are checked.
In your code you can write something like this:
      CString Enter;
      Enter=char(13);
      Enter += char(10);
      m_edit1="Hello"+Enter+"World";
      UpdateData(FALSE);

0
 
LVL 4

Expert Comment

by:pagladasu
Comment Utility
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);

0
 
LVL 2

Expert Comment

by:jrmcg
Comment Utility
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.


0
 

Author Comment

by:samyee
Comment Utility
Thanks pagladasu!!!

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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now