I have in my C# program textBox
I need that when the program start, the focus will be on the textBox
I try this on Form_Load:
MyTextBox.Focus
use form shown event and set
MyTextBox.Focus();
In jquery set focus
$(function() {
$("#txtBox1").focus();
});
or in Javascript you can do
window.onload = function() {
document.getElementById("txtBox1").focus();
};
check your tab order and make sure the textbox is set to zero
You can use either textBox1.select();
or the TabIndex in textbox setting. TabIndex=0
focoused first.
Set Tab Index property's value = 0 and then in form load function write :
YourTextboxName.Focus();
It will work.
Set Tabstop to True and TabIndex to the minimum to the control on which you need focus.
e.g. If you have 2 TextBoxes : TextBox1 and TextBox2, set Tabstop to True for both and TabIndex to 0 and 1 respectively. When the form loads, the focus will be on TextBox1 and on the press of 'Tab' key, the focus will move to TextBox2.