Solved

HELP: New line in CEdit

Posted on 1998-10-21
4
360 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
ID: 1323609
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
ID: 1323610
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
ID: 1323611
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
ID: 1323612
Thanks pagladasu!!!

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

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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.

791 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