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

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

 

▶ 예제 코드 (C#)

using System.Windows.Controls;

#region 현재 열 구하기 - GetCurrentColumn(textBox)

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

    return column;
}

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

댓글을 달아 주세요