1
我已经添加了一个StatusStrip
控件,并在其中放置StatusLabel
。但是现在我想知道如何将它连接到我的文本框来显示光标的行号和位置,如:“第2行,第6行”。如何在状态栏的文本框中显示行位置?
谢谢
我已经添加了一个StatusStrip
控件,并在其中放置StatusLabel
。但是现在我想知道如何将它连接到我的文本框来显示光标的行号和位置,如:“第2行,第6行”。如何在状态栏的文本框中显示行位置?
谢谢
获取TextBox中插入符号的索引:
C#
int caretIndex = textBox.SelectionStart;
VB.NET
Dim caretIndex As Integer = textBox.SelectionStart
获得从插入符号索引的行号:
C#
int lineNumber = textBox.GetLineFromCharIndex(caretIndex);
VB.NET
Dim lineNumber As Integer = textBox.GetLineFromCharIndex(caretIndex)
获取当前行的字符索引:
C#
Point characterXY = textBox.GetPositionFromCharIndex(caretIndex);
int characterIndex = textBox.GetCharIndexFromPosition(characterXY);
VB.NET
Dim characterXY As Point = textBox.GetPositionFromCharIndex(caretIndex)
Dim characterIndex As Integer = textBox.GetCharIndexFromPosition(characterXY)
我想你可以继续从这里...