在winform的文本框中,如何获取当前输入位置?
例如 -
textbox.text = 3056.98
如果在'0'后面键入'7',则当前输入位置为3。
在vb.net中,哪个文本框事件或关键字可以获取此位置值?
例如 -
textbox.text = 3056.98
如果在'0'后面键入'7',则当前输入位置为3。
在vb.net中,哪个文本框事件或关键字可以获取此位置值?
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 Integer = textBox.GetLineFromCharIndex(caretIndex)
Get the character index in the current line:
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)
我猜你可以从这里继续...
对于Winforms的TextBox,您可以使用SelectionStart
属性获取当前光标位置。
在WPF中,可以使用CaretIndex
属性找到相同的内容。
不确定ASP.NET - 我怀疑您无法从服务器端检索此内容。