TCSGrad
TCSGrad

Reputation: 12128

Write formatted text(printf style) to a MFC CEdit control, which would display the formatted text in a EditControl?

I need to display text along with values of variables in a CEdit controlled Edit Control Box. How do I do it ? Currently I'm using SetWindowText(), but that only takes a string...how do I get a formatted string to display in the edit control?

Example: printf("The answer is %d\n",ans) -> how do i print the same message in a Edit Control?

Upvotes: 0

Views: 2381

Answers (1)

Nikola Smiljanić
Nikola Smiljanić

Reputation: 26863

Use CString's Format member.

CString text;
text.Format(_T("The answer is %d\n"), ans);
edit.SetWindowText(text);

Upvotes: 4

Related Questions