怎样获取 edit控件读取每行信息的字符个数

2024-11-29 10:49:10
推荐回答(1个)
回答(1):

m_Edit.GetLine(0,lpszBuffer);//读取edit控件中第一行文本存入lpszBuffer指向的字符串中,m_Edit是与edit控件关联的变量
可参考代码:
int i, nLineCount = m_myEdit.GetLineCount();//m_myEdit是与edit控件关联的变量

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);//输出得到的每行数据
}