CRichEditCtrl::LineIndex

检索一行的字符的索引本 CRichEditCtrl 对象中。

int LineIndex(
   int nLine = -1 
) const;

参数

  • nLine
    在编辑控件的文本包含所需行的索引值或包含– 1。 如果 nLine 为– 1,它指定当前行,即,一个包含插入符号的行。

返回值

在 nLine 指定的行的字符索引或– 1;如果指定的行号较大的然后的行数在编辑控件中。

备注

字符的索引是字符数从最初rich edit控件添加到指定的行。

有关更多信息,请参见 Windows SDK的 EM_LINEINDEX

示例

// The string for replacing.
LPCTSTR lpszmyString = _T("Hello, I'm the new second line.");

int nBegin, nEnd, nIndex;

// Replace the second line, if it exists, of the rich edit control
// with the text lpszmyString.
nIndex = m_myRichEditCtrl.LineIndex(1);
if ((nBegin = nIndex) != -1)
{
   nEnd = nBegin + m_myRichEditCtrl.LineLength(nIndex); 
   m_myRichEditCtrl.SetSel(nBegin, nEnd);
   m_myRichEditCtrl.ReplaceSel(lpszmyString);
}   

要求

Header: afxcmn.h

请参见

参考

CRichEditCtrl选件类

层次结构图

CRichEditCtrl::LineFromChar

CRichEditCtrl::GetLineCount