Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

HELP: New line in CEdit

Posted on 1998-10-21
4
Medium Priority
?
395 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 150 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Suggested Courses

824 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