Reputation: 10928
I open a custom form from another with ShowDialog(),
The problem is that this freshly opened form is not already selected, but just on top. This causes that I can't capture key presses or have my first tab index already selected until I click once on the form.
Anyone can help me ?
I already tried these in the Form_Load and it doesn't work yet :
Me.Activate()
Me.BringToFront()
Me.Focus()
Me.Show()
Me.Select()
I did not found an answer yet from searching on Google.
Upvotes: 3
Views: 1246
Reputation: 126
You should try this if you don't have a very slow computer :
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
ClickForm.Interval(1000)
ClickForm.Start()
'Set the interval and start the timer
End Sub
Private Sub ClickForm_Tick(sender As Object, e As EventArgs) Handles ClickPanel.Tick
'Wait for form charging
Me.Select()
'Select the form
End Sub
Obviously you need to add a timer to your project...
Upvotes: 1
Reputation: 1182
It sounds you have a timer
or a handler
that handles
and focus
on the above form so you loose the focus on the freshly dialogued form.
Solution: - Remove the loop or handler that focus on your form and do it on a background or something more external or after the Form_Load.
*To be clear: when you use ShowDialog() the form will be shown on TopMost so the other form will be sent to the front you cant focus on it till the Dialog will be closed
Upvotes: 1