简体   繁体   English

MFC编辑控件更新

[英]MFC edit control update

I try to update an edit control's text, using it's added variable, which is a CString but i'm failing it. 我尝试更新编辑控件的文本,使用它添加的变量,这是一个CString但我失败了。

m_sNrAuto = "some text";  
UpdateData(TRUE);

I also tried using UpdateWindow() , but the edit control remains blank. 我也尝试使用UpdateWindow() ,但编辑控件仍为空白。 I know i can do it by using SetWindowText() , but i also saw some snippets where SetWindowText() it's not used, the update is done by passing a value to an affiliated CString. 我知道我可以通过使用SetWindowText()来实现它,但我也看到了一些片段,其中没有使用SetWindowText() ,更新是通过将值传递给附属的CString来完成的。

Try UpdateData(false); 尝试UpdateData(false);

  • true means Control=>Data true表示Control => Data

  • false means Data=>Control false表示Data => Control

Sometimes you have to do 有时你必须这样做

UpdateData(true);  // snapshot ALL controls data
m_sNrAuto = "some text";  // tweak the one you actually need updated
UpdateData(false);  // this pushes ALL data, not just the one you tweaked

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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