Setting the text on a CEdit Control

Posted on 2002-05-27
Last Modified: 2013-11-20
The the situation is as follows.

I have a CStringList with an un known number of strings stored in it (rollResults). I also have a CEdit control for output (m_rollResults). Each string ends with a '\n' character.

CStringList output;
// m_rollResults is type CEdit
// fill out put with various data

// clear anything in the in the edit box
m_rollResults.SetSel(0, -1);

// place all the strings in output, into m_rollResults
for(POSITION pos = output.GetHeadPosition(); pos != NULL; )

Everything seems to work except all the output is placed on one line. I do not want to use word wrap or anything like that. I want each string to be placed on a new line in the CEdit control. I have tryed placing a '\n', '\r', and '\0' char at the end of each line but all it did was print an unknow char.

I know I am doing things in a round about way. I will up the point if anyone can show me the proper way of doing this.
Question by:gandalf79
  • 2
  • 2
  • 2
LVL 86

Expert Comment

ID: 7037829
You will have to put a "\r\n" at the end of each line to achieve the desired effect.

Author Comment

ID: 7037835
I tried that but it would only print those unknown char boxes.
LVL 86

Accepted Solution

jkr earned 150 total points
ID: 7037839
Do you have "multiline" enabled? "\r\n" used to work the last 10 years...
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.


Author Comment

ID: 7037851
Thanks for your help. Feel kind of silly now knowing the answer was as simple as a check box i had looked at several times. I appriseate your quick responce.

LVL 16

Expert Comment

ID: 7037861
2 gandalf79
>Each string ends with a '\n' character.
It is possible that you have "\n\r\n".
First try to remove '\n' and add "\r\n". (Or replace last character)
In addition, you must check that your edit control has style "Multiline". (Use resource editor)

LVL 16

Expert Comment

ID: 7037863
I'm sorry, I have only first 3 posts when I start to answer.

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Error on moodle after upgrade 3 130
wait notify demo infinite loop 3 110
Unix Command -- Challenging  question 7 88
Capture logon name 13 70
Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

785 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