Beispiel #1
0
        private void DisplayCurrentLineAndColumnIndex()
        {
            int line = TextBox1.GetLineFromCharIndex(TextBox1.SelectionStart);

            int column = TextBox1.SelectionStart - TextBox1.GetFirstCharIndexFromLine(line);



            //int currentLineIndex = TextBox1.GetLineFromCharIndex(TextBox1.SelectionStart);
            //int lengthOfpreviousLines = 0;
            //if (currentLineIndex > TextBox1.Lines.Length)
            //{
            //    currentLineIndex = TextBox1.Lines.Length;
            //}
            //for (int i = 0; i < currentLineIndex; i++)
            //{
            //    lengthOfpreviousLines += TextBox1.Lines[i].Length;
            //    lengthOfpreviousLines += "\r\n".Length;
            //}
            //int currentColiumnIndex = TextBox1.SelectionStart - lengthOfpreviousLines;

            //LabelLineColumn.Text = string.Format("Ln {0}, Col {1}", currentLineIndex + 1, currentColiumnIndex + 1);
            LabelLineColumn.Text = string.Format("Ln {0}, Col {1}", line + 1, column + 1);
        }
Beispiel #2
0
 private int GetLineNumber()
 {
     return(TextBox1.GetLineFromCharIndex(TextBox1.SelectionStart));
 }