CEdit::LineIndex

调用该函数检索一行索引在多行中的edit控件的字符。

int LineIndex( 
   int nLine = -1  
) const;

参数

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

返回值

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

备注

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

此成员函数由多行只处理编辑控件。

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

示例

// The string for replacing.
CString strString(_T("Hi, we're the replacements."));
int nBegin, nEnd;

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

要求

Header: afxwin.h

请参见

参考

CEdit Class

层次结构图

CEdit::LineFromChar