Lijo
March 31st, 1999, 08:43 AM
Hi,
How can I put a new line in an edit control dynamically....
regards,
Lijo
How can I put a new line in an edit control dynamically....
regards,
Lijo
|
Click to See Complete Forum and Search --> : How can I Put a new line in an edit control dynamically Lijo March 31st, 1999, 08:43 AM Hi, How can I put a new line in an edit control dynamically.... regards, Lijo Bore March 31st, 1999, 08:48 AM You have to get the text from the edit control with CWnd::GetWindowText(). Then change the text according to your needs, and send it back to the edit control with CWnd::SetWindowText(). Sergio Acosta May 30th, 1999, 12:42 AM A way to do it without having to take all the text and replace it is to take the cursor to the last position of the edit box, and then use ReplaceSel() to replace the current selected text (the selection will be empty so it will be actually an insertion). To take the cursor to the last position I do this: m_Edit.SetSel(0,-1,FALSE); m_Edit.SetSel(-1,0,TRUE); The first SetSel will select all the text in the edit box, the FALSE indicates that the cursor will be taken (scrolled) to the selection. The second call will select no text, but it will not move the cursor. Once the cursor is at the end you can add text : m_Edit.ReplaceSel("new line of text") Besides, another thing is that you can't put a new line using: myEdit.SetWindowText("\n"). You have to do it like this: myEdit.SetWindowText((CString)'\r'+(CString)'\n'). Isn't that annoying?. It is incredible that MFC doesn't provide such simple features for such a wide-use control. codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |