Jota Santana
Jota Santana

Reputation: 33

Change tab order inside ToolStripMenu

When the ToolStrip control is focused the first ToolStripItem is focused too.
I need to set the focus to the second item, but there is no TabIndex property in ToolStripItems.
I've tried to select the item manually when the ToolStrip gets the focus, but there is no Focus method either.
Actually, we use a inherited control, so I can create custom properties/methods, if it's needed.

Any idea on how to achieve this?

Upvotes: 1

Views: 237

Answers (1)

LarsTech
LarsTech

Reputation: 81620

The ToolStrip is doing something when it fires the Enter event, so just setting the focus on a ToolStripItem won't work unless you focus after the enter event code has completed. The BeginInvoke method is a way to run code after the event has finished:

Private Sub ToolStrip1_Enter(sender As Object, e As EventArgs) Handles ToolStrip1.Enter
  Me.BeginInvoke(New Action(Sub()
                              ToolStrip1.Items(1).Select()
                            End Sub))
End Sub

Upvotes: 1

Related Questions