There must be a form for input data in the database project. The biggest headache for entry personnel is that you need to move the mouse or press the tab button with the other hand after each data entry (but it is still very troublesome ). The most humane way is to press the Enter key (you only need to enter one hand in the keypad) and use the direction key to control it.
Step 1: The keypreview attribute of form is true;
Step 2: Set tabindex in sequence as needed;
Step 3: compile a method with the following code:
'--- Focusmove is function name -- '--- Controlname is the control's name which you want to use --- Private sub focusmove () sub focusmove (byval sender as object, Byval e as system. Windows. Forms. keypresseventargs) handles controlname1.keypress, Controlname2.keypress If E. keychar = chrw (13) then '--- Selectnextcontrol is a function will be introduced next --- Selectnextcontrol (sender, true, false) End if End sub |
The description of selectnextcontrol comes from msdn:
Activate the next control.
[Visual Basic] Public Function selectnextcontrol (_ Byval CTL as control ,_ Byval forward as Boolean ,_ Byval tabstoponly as Boolean ,_ Byval nested as Boolean ,_ Byval wrap as Boolean _ ) As Boolean [C #] Public bool selectnextcontrol ( Control CTL, Bool forward, Bool tabstoponly, Bool nested, Bool wrap ); [C ++] Public: bool selectnextcontrol ( Control * CTL, Bool forward, Bool tabstoponly, Bool nested, Bool wrap ); [JScript] Public Function selectnextcontrol ( CTL: control, Forward: Boolean, Tabstoponly: Boolean, Nested: Boolean, Wrap: Boolean ): Boolean; |
Parameters:
◆ CTL
The control from which the search starts.
◆ Forward
If it is true, it is moved forward in the tab key order; if it is false, it is moved backward in the tab key order.
◆ Tabstoponly
True indicates that the control whose tabstop attribute is set to false is ignored; false indicates that the control is not ignored.
◆ Nested
True indicates including nested child controls (child Controls); false indicates not including.
◆ Wrap
True indicates that the search continues from the first control in the tab key order after the last control is reached. False indicates that the search does not continue.
◆ Return Value
True if the control is activated; otherwise, false.
Note:
If the controlstyles. if the selectable style bit is set to true and the control is included in another control, and all its parent controls are visible and enabled, the selectnextcontrol method activates the next control in the tab key sequence.
The Windows Forms control in the list below is not selectable. Controls derived from controls in the list are also not selectable.
◆ Label
◆ Panel
◆ Groupbox
◆ Picturebox
◆ Progressbar
◆ Splitter
◆ Linklabel (when no link exists in the control)
Requirements:
Platform: Windows 98, Windows NT 4.0, Windows ME, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 Series
The last note is the tabindex settings. If the control is in groupbox, groupbox must be in the tabindex order, that is, if textbox1 is in groupbox1, groupbox1.index = 1, textbox1.index = 2. And in selectnextcontrold, the parameter nested = true. There are also some details that you should pay more attention to when using them.