how do i code this in vb.net:
我如何在vb.net中编码:
focus the textbox and get the cursor to the rightmost digit?
聚焦文本框并将光标移到最右边的数字?
1 个解决方案
#1
In a WindowsForm you can use:
在WindowsForm中,您可以使用:
Me.TextBox1.Focus()
Me.TextBox1.SelectionStart = TextBox1.Text.Length
In a WebForm you can set the focus using a javascript function like this:
在WebForm中,您可以使用如下的javascript函数设置焦点:
function setCursorPosition(elemId, cursorPosition) {
var element = document.getElementById(elemId);
if(element != null) {
if(element.selectionStart) {
element.focus();
element.setSelectionRange(cursorPosition, cursorPosition);
}
else
element.focus();
}
}
#1
In a WindowsForm you can use:
在WindowsForm中,您可以使用:
Me.TextBox1.Focus()
Me.TextBox1.SelectionStart = TextBox1.Text.Length
In a WebForm you can set the focus using a javascript function like this:
在WebForm中,您可以使用如下的javascript函数设置焦点:
function setCursorPosition(elemId, cursorPosition) {
var element = document.getElementById(elemId);
if(element != null) {
if(element.selectionStart) {
element.focus();
element.setSelectionRange(cursorPosition, cursorPosition);
}
else
element.focus();
}
}