mfc读取多行编辑框的数据

2025-03-13 20:37:21
推荐回答(1个)
回答1:

方法如下:
CEdit类的方法:
int GetLineCount( )
int GetLine( int nIndex, LPTSTR lpszBuffer, int nMaxLength )

这是MSDN的官方示例:
先为Textbox绑定一个CEdit类的变量123456789101112int i, nLineCount = m_myEdit.GetLineCount();CString strText, strLine;// Dump every line of text of the edit control.for (i=0; i < nLineCount; i++){ // length of line i: int len = m_myEdit.LineLength(m_myEdit.LineIndex(i)); m_myEdit.GetLine(i, strText.GetBuffer(len), len); strText.ReleaseBuffer(len); strLine.Format(_T("line %d: '%s'\n"), i, strText); AFXDUMP(strLine);}