CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    May 1999
    Posts
    327

    how do I define a new line for edit box

    I have a multi-line edit box. Currently I type something like the following;

    m_edit1 = "text, text, text";
    UpdateData(FALSE);

    and text appears in the edit box. I want to type alot of text though and when
    I do that, it all appears on the first line only. How can I declare a new line in the
    edit box?

    When I type

    m_edit1 = "text, text, text \n
    newtext";

    I get errors!

    Any response anyone can give me will be greatly appreciated.



  2. #2
    Guest

    Re: how do I define a new line for edit box

    Set properties of your edit control to multi-line in resource editor(or programmatically).
    Use the sequence "\r\n".
    F.i., pEdit->SetWindowText("First line\r\nSecond line\r\nThird line");


  3. #3
    Join Date
    May 1999
    Posts
    327

    Re: how do I define a new line for edit box

    If I type,

    m_edit1 -> SetWindowText("Firstline\r\nSecond line\r\n");

    I get the error

    'CString does not have an overloaded member operator ->'

    Please, is there something I am doing wrong?


  4. #4
    Join Date
    May 1999
    Posts
    82

    Re: how do I define a new line for edit box

    The -> operator is only used when you have a pointer to an object. If your using a member variable you only need to use a period. Like so...

    m_edit1.SetWindowText("Firstline\r\nSecond line\r\n");


  5. #5
    Join Date
    May 1999
    Location
    Seattle, WA USA
    Posts
    423

    Re: how do I define a new line for edit box

    if m_edit1 is a CString in your code, it doesn't have the SetWindowText function either. Is m_edit1 the member vaiable you associated with your edit box? If so, you would probably do something like:
    m_edit1 = "First\r\nSecond\r\n";
    UpdateData (FALSE);

    And make sure your editbox has the multiline property set.

    --michael


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured