첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
728x90
반응형
728x170

■ TextBox 클래스의 GetLineIndexFromCharacterIndex 메소드를 사용해 현재 줄의 인덱스를 구하는 방법을 보여준다.

 

▶ 예제 코드 (C#)

using System.Windows.Controls;

#region 현재 줄 구하기 - GetCurrentLine(textBox)

/// <summary>
/// 현재 줄 구하기
/// </summary>
/// <param name="textBox">텍스트 박스</param>
/// <returns>현재 줄</returns>
public int GetCurrentLine(TextBox textBox)
{
    int index = this.textBox.SelectionStart;
    int line  = this.textBox.GetLineIndexFromCharacterIndex(index);

    return line;
}

#endregion
728x90
반응형
그리드형(광고전용)
Posted by icodebroker

댓글을 달아 주세요