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

    How to make an Editbox display a string

    I want an Editbox to display a string. And as soon as I change the string, I want the editbox to update it. The second part with the update isn't necessary.

    Can anyone help me with this please?


  2. #2
    Join Date
    May 1999
    Posts
    42

    Re: How to make an Editbox display a string

    Since you don't mention your programming environment, I'll assume it is VC5 or VC6.

    CWnd::SetWindowText() can be used to set the contents of the edit box.

    For the updating, use the Class Wizard's Message Map to map the EN_CHANGE notification message. Whenever the contents of the edit box changes, this method will be called. Inside this method, put code to update your string variable.

    Example:

    // in your initialization code
    CString cSample("This is edit box text");
    m_editBox.SetWindowText( cSample );

    CSample::OnChangeEdit1()
    {
    cSample = m_editBox.GetWindowText();
    }


  3. #3
    Join Date
    May 1999
    Posts
    10

    Re: How to make an Editbox display a string

    Actully I use VC 4, but I hope it won't make much of a difference.


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