Home > Software engineering >  The new consult, how to start form the beginning, the cursor focus on a certain texbox? In texbox in
The new consult, how to start form the beginning, the cursor focus on a certain texbox? In texbox in

Time:09-18

The new consult, how to start form the beginning, the cursor focus on a certain texbox? In texbox input correctly to jump to other texbox control implementation?
Due to the new, foundation is weak, so problem superficial or very unreliable, but great spirit in the BBS, please do not laugh and glad! Thank you very much!

CodePudding user response:

With textbox1. The setfocus to set the current focus to textbox1

form_load, set the focusTextbox1_LostFocus, set the focus,

CodePudding user response:

Need to show before the load

CodePudding user response:

In your Form design window, use the mouse to select the TextBox, then put it in the properties window of the TabIndex attribute to 0, so, in the Form starts, it gains focus by default,

CodePudding user response:

 
Private sub Form_Load ()
Me. Show
Text1. SetFocus
End Sub
Private sub Text1_LostFocus ()
If Text1. Text & lt;> "Test" right Then Text1. SetFocu
End Sub

CodePudding user response:

Private Sub Form_Load ()
Me. Show
Text1. SetFocus
End Sub
In the design of interface, Text1 TabIndex attribute is set to 0, the Text2 TabIndex attribute is set to 1, will Text3 TabIndex attribute is set to 2... After fill in the content such as Text1 press [Tab] can move focus in turn,

CodePudding user response:

Like they say, the old version set focus is textbox. Setfocus,
In the 2008 version directly is textbox. Fous, will not used to?

CodePudding user response:

This trivial change, have what not accustomed to,

CodePudding user response:

refer to 7th floor Chen8013 response:
this trivial change, have what not accustomed to,


That someone is virgo,

CodePudding user response:

refer to 6th floor diaocanfa response:
as they say, the old version set focus is textbox. Setfocus,
In the 2008 version directly is textbox. Fous, will not used to?

Mention is a vb6 or ask questions. NET will be a little better, VB section mainly discuss the related topics of vb6,. NET have special edition piece, discussion. The problem of NET targeted stronger,
To.net, vb will be more to keep unified with the platform, so as to properly sell some historical burden, thus from vb6 to. NET will be a slight difference, since almost the same inherited grammar before again, so can be very smooth transition, and greatly reduce the learning cost, what do you mean by this change, as long as met once, sure you should know how to write the next time, plus VS intellisense, this change is not the problem, completely accustomed to later, c # can deliver,

CodePudding user response:

Should not be in the form_load () set in the focus, should be in form_activate () set in the focus

CodePudding user response:

1 in the event of an Form_Activate Text1 get focus,
2 in the event of an Text1_Validate Text1 content examination, correct are allowed to leave,
3 will Exit the category button CauseValidate attribute is set to False, so can't correct input Text1 cannot Exit,

 Option Explicit 

Private Sub Command1_Click ()
Unload Me
End Sub

Private Sub Form_Activate ()
Text1. SetFocus
End Sub

Private Sub Form_Load ()
Command1. Caption="E& Xit
"Command1. CausesValidation=False
End Sub

Private Sub Text1_Validate (Cancel As Boolean)
If Text1 & lt;> "1234" Then Cancel=True
End Sub

Another way is to remove Form_Activate events, set in Formload Text1 TabIndex=0:
 Private Sub Form_Load () 
Command1. Caption="E& Xit
"Command1. CausesValidation=False

Text1. TabIndex=0
End Sub
  • Related