Navigate between controls

Anders

New member
Local time
Today, 14:04
Joined
Apr 13, 2001
Messages
5
I have some textboxes, checkboxes etc. on a form. As it is now I can move between them, using both the TAB-key and also the arrow-keys. Can it be changed, so only the TAB-key can be used to navigate between the controls, and the arrow-keys only are used within a textbox or a combobox???
 
Hi. You can set the arrow keys behavior for the entire application by selecting Tools>Options and going to the 'Keyboard' tab. If you're looking to change its behavior in just that form, you can do it by setting the property during the Activate and Deactivate events.
  • Private Sub Form_Activate()
    SetOption "Arrow Key Behavior", 1
    End Sub

    Private Sub Form_Deactivate()
    SetOption "Arrow Key Behavior", 0
    End Sub

Additionally, you can use the forms 'KeyDown' propery and the various controls 'Tag' propery to disable the arrow keys in the selected controls. The following code will cause the form to ignore the arrow keys for any field where you set the 'Tag' to 'NA'. Note, you'll also need to set the forms 'KeyPreview' to Yes.
  • Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode > 36 And KeyCode < 41 And Me.ActiveControl.Tag = NA Then KeyCode = 0
    End Sub

Hope this helps.
~Abby

[This message has been edited by Abby N (edited 04-19-2001).]
 

Users who are viewing this thread

Back
Top Bottom