■ TextBox 클래스의 GetLineIndexFromCharacterIndex 메소드를 사용해 현재 줄의 인덱스를 구하는 방법을 보여준다.
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
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 |