Moving Focus using Tab key....

In vb6 form I've 1 Textbox, 2 option buttons & 1 command button
my need is I want to move from one option button to other by pressing
Tab key. Help me out. This is customer requirement.

Comments

  • : In vb6 form I've 1 Textbox, 2 option buttons & 1 command button
    : my need is I want to move from one option button to other by pressing
    : Tab key. Help me out. This is customer requirement.
    :
    [code]
    Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    If KeyCode = 9 Then
    If Me.Option1.Value Then
    Me.Option2.SetFocus
    Else
    Me.Option1.SetFocus
    End If
    End If
    End Sub
    [/code]
  • : : In vb6 form I've 1 Textbox, 2 option buttons & 1 command button
    : : my need is I want to move from one option button to other by pressing
    : : Tab key. Help me out. This is customer requirement.
    : :
    : [code]:
    : Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    : If KeyCode = 9 Then
    : If Me.Option1.Value Then
    : Me.Option2.SetFocus
    : Else
    : Me.Option1.SetFocus
    : End If
    : End If
    : End Sub
    : [/code]:

    Why not use the TabIndex properties of the controls?
    When pressing Tab, the focus will shift to the smallest index that is larger than the current one (often current index + 1), and shift+tab does the reverse.

    So, all you need to do is set the TabIndex properties correctly for the controls.

    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • : : : In vb6 form I've 1 Textbox, 2 option buttons & 1 command button
    : : : my need is I want to move from one option button to other by pressing
    : : : Tab key. Help me out. This is customer requirement.
    : : :
    : : [code]: :
    : : Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    : : If KeyCode = 9 Then
    : : If Me.Option1.Value Then
    : : Me.Option2.SetFocus
    : : Else
    : : Me.Option1.SetFocus
    : : End If
    : : End If
    : : End Sub
    : : [/code]: :
    :
    : Why not use the TabIndex properties of the controls?
    : When pressing Tab, the focus will shift to the smallest index that
    : is larger than the current one (often current index + 1), and
    : shift+tab does the reverse.
    :
    : So, all you need to do is set the TabIndex properties correctly for
    : the controls.
    :
    : Best Regards,
    : Richard
    :
    : The way I see it... Well, it's all pretty blurry
    :
    Hate to say that. Theoretically it is very good idea. Practically it does not work.
  • You can use a work around, but it will require some extensive coding to make it work.

    Place each RadioButton within a separate Frame. Set each of the Frame's BorderStyle to none.

    This should allow you to tab to each of the RadioButtons, but again, you'll have to do a bit of tricky coding to turn off all other RadioButtons when one is selected.

    Good luck, I hope this helps.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories