Solved

HELP: New line in CEdit

Posted on 1998-10-21
4
367 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

726 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