简体   繁体   中英

How change edit control's text?

I have a button and text control in MFC dialog window, when I click on button, in edit control must be replaced for example "hello world" .
but if I write

edit="hello wordl"

it doesn't change, how can I change?

First you should add a variable to edit.To do that right click on the edit and choose Add Variable... in Add Member variable Wizard change Category from Control to Value after that in the Variable name field type a name like m_EditValue then click finish.from now you can change the Edit Control simply by following code.

   void CAboutDlg::OnBnClickedButton1()
    {
        // TODO: Add your control notification handler code here
        m_EditValue = L"Hello World";
        UpdateData(FALSE);
    }

使用SetWindowText方法:

edit.SetWindowText( _T("Hello, World!") );

First you need a CEdit member variable of the dialog. Use 'Add Variable' in the dialog editor. If you name this variable m_helloedit then in your button click function

m_helloedit.SetWindowText(_T("hello world!"));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM