我添加了一个StatusStrip
控件,并在其中放置了一个StatusLabel
。但是现在我想知道如何将它连接到我的文本框,以显示行号和光标的位置,如:" line 2, Row 6"。
Thank you
-
获取文本框中插入符号的索引:
c#int caretIndex = textBox.SelectionStart;
VB。
Dim caretIndex As Integer = textBox.SelectionStart
-
从插入符号索引中获取行号:
c#int lineNumber = textBox.GetLineFromCharIndex(caretIndex);
VB。
Dim lineNumber As Integer = textBox.GetLineFromCharIndex(caretIndex)
-
获取当前行的字符索引:
c#Point characterXY = textBox.GetPositionFromCharIndex(caretIndex); int characterIndex = textBox.GetCharIndexFromPosition(characterXY);
VB。
Dim characterXY As Point = textBox.GetPositionFromCharIndex(caretIndex) Dim characterIndex As Integer = textBox.GetCharIndexFromPosition(characterXY)