Hope someone has a solution or some suggestions for this.
This cannot be right?!?
Problem:
I have multiple non-modal forms open at the same time.
One or more of these forms have a ToolStrip, each of which has
one or more ToolStripButton s.
If, say, form A has got the focus and I click a ToolStripButton on
form B, the button does not react at first: What happens is that
form B gets the focus on the first click and THEN I have to click
a second time for the ToolStripButton to fire its Click event.
If form B already had the focus, the Click event would fire the
first time.
The following code illustrates the problem:
Create a new project, add a Button control, a ToolStrip control,
and on the ToolStrip control, three ToolStripButton controls
(or one, for that matter) and paste the code below into form1.
Run the program and click the button to create a second form.
Now try getting a ToolStripButton control to fire its click event
without the form on which it resides having the focus first.
---snip---
Option Explicit On
Option Strict On
Public Class Form1
Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As System.EventArg s) Handles Button1.Click
Dim frm As New Form1
frm.Show()
End Sub
Private Sub ToolStripButton 1_Click(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles ToolStripButton 1.Click
MsgBox("Click1" )
End Sub
Private Sub ToolStripButton 2_Click(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles ToolStripButton 2.Click
MsgBox("Click2" )
End Sub
Private Sub ToolStripButton 3_Click(ByVal sender As System.Object,
ByVal e As System.EventArg s) Handles ToolStripButton 3.Click
MsgBox("Click3" )
End Sub
End Class
---snip---
Regards,
How do I get the ToolStripButton to fire its click event regardless of
whether its form already has got the focus?
(Note: There is no problem clicking the normal button, form focus or
not.)
?
TIA,
Joergen Bech
Comment