how to put focus on TextBox when the form load?

前端 未结 16 1201
清歌不尽
清歌不尽 2020-12-04 14:59

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         


        
16条回答
  •  甜味超标
    2020-12-04 15:18

    In jquery set focus

    $(function() {
      $("#txtBox1").focus();
    });
    

    or in Javascript you can do

    window.onload = function() {
      document.getElementById("txtBox1").focus();
    };
    

提交回复
热议问题