} // END private void MainForm_Shown(object sender, EventArgs e) /// <summary> /// This updates the row and col numbers when: /// 1 - The CSTextBox has the focus AND /// 2 - there is something in the textbox /// /// The compiler ignores code lines that start with "using" because they /// are for the IDE, not the compiler, and also ignores comment-only lines. /// </summary> private void DoStatusBar() { if (CSTextBox.Focused) { if (CSTextBox.Text.Length == 0) { RowColStatus.Items["RowNum"].Text = "Row 1"; RowColStatus.Items["ColNum"].Text = "Col 1"; } // END if (CSTextBox.Text.Length == 0) else { if (CSTextBox.SelectionLength > 1) { RowColStatus.Items["RowNum"].Text = ""; RowColStatus.Items["ColNum"].Text = ""; } else { // Courtesy pf http://www.codeproject.com/Tips/292107/TextBox-cursor-position Int32 CharPos = CSTextBox.SelectionStart; Int32 LineNum = CSTextBox.GetLineFromCharIndex(CharPos); Int32 ColNum = CSTextBox.SelectionStart - CSTextBox.GetFirstCharIndexFromLine(LineNum); RowColStatus.Items["RowNum"].Text = $"Row {(LineNum + 1).ToString()}"; RowColStatus.Items["ColNum"].Text = $"Col {(ColNum + 1).ToString()}"; } } // END else of [if (CSTextBox.Text.Length == 0)] } // END if (CSTextBox.Focused) else { RowColStatus.Items["RowNum"].Text = ""; RowColStatus.Items["ColNum"].Text = ""; } } // END private void DoStatusBar()
private void CSTextBox_Click(object sender, EventArgs e) { CSTextBox.SelectAll(); }