How can I display the line position in a TextBox on the status bar?
问题 I have added a StatusStrip control and placed a StatusLabel inside of it. But now I want to know how to connect it to my TextBox to show the line number and position of the cursor, like: "Line 2, Row 6". Thank you 回答1: Get the index of the caret in the TextBox: C# int caretIndex = textBox.SelectionStart; VB.NET Dim caretIndex As Integer = textBox.SelectionStart Get the line number from the caret index: C# int lineNumber = textBox.GetLineFromCharIndex(caretIndex); VB.NET Dim lineNumber As