473,775 Members | 2,432 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ToolStripButton does not fire click event if form does not have focus?


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

Jun 27 '08 #1
2 7197

"Joergen Bech" <jb***@post1.te le.dkwrote in message
news:h9******** *************** *********@4ax.c om...
>
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
That is windows. There used to be an option in the mouse dialog that
allowed a emulation ( I believe of X-Windows) where when you moved the mouse
over a window it gained focus. I don't see that in Vista. You will get
behaviour in any windows app.

You could capture the mouse enter event and give focus to you app (the
appropriate window) and that would get rid of the standard behaviour.

LS

Jun 27 '08 #2
On Mon, 28 Apr 2008 18:27:23 -0400, "Lloyd Sheen" <a@b.cwrote:
>
"Joergen Bech" <jb***@post1.te le.dkwrote in message
news:h9******* *************** **********@4ax. com...
>>
---snip---
>
That is windows. There used to be an option in the mouse dialog that
allowed a emulation ( I believe of X-Windows) where when you moved the mouse
over a window it gained focus. I don't see that in Vista. You will get
behaviour in any windows app.

You could capture the mouse enter event and give focus to you app (the
appropriate window) and that would get rid of the standard behaviour.

LS
Sorry, but I do not understand what you mean.

I have not seen any similar behavior in other programs, so this
is definitely not standard Windows behavior.

In other applications I have no problems switching to
another form by clicking on a tool button or control.

But never mind. I found this link, which explains it all:
http://blogs.msdn.com/rickbrew/archi...09/511003.aspx

/JB

Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
6829
by: Carlo Marchesoni | last post by:
From an aspx page (A.aspx) I open another one (B.aspx - for table lookup). When the user selects an entry in B.aspx I would like to force a button's event in A.aspx to be fired. I guess the only way is using javascript - does anybody have a sample for this ? Thanks
1
1313
by: shland | last post by:
Is there a way I can trigger the click event of a button while I'm processing (server-side) the click of another button? I know this is available in Windows forms, but what about ASP.NET? Thanks, Sheryl
1
1090
by: shland | last post by:
This is related to my previous post on "fire click event from serverside code?" Alternately, is there a way to intercept a click event on a control from a referenced .dll, and do some pre-processing prior to allowing the click event processing to occur in the .dll? Background - I'm using a button control from a .dll for which I do not have source code, and before the .dll processes the button click, I want to save information entered...
3
6703
by: JD | last post by:
Hello, I have a problem with checkboxlist inside Repeater (in ASP.NET page). I am able to create Checkboxlist and bind it (inside Repeater_ItemBound - including setting checked/unchecked). Checkboxlist has Autopostback=true so whenever I click on checkbox, the page is submitted to the server. Here starts my problem: I am not able to capture the click event of checkbox list to find out which checkbox was clicked (which generated click...
3
7077
by: TCORDON | last post by:
Why does the click event of an image button that submitts a form does not get fired when ENTER is pressend on a textbox of that form? How can I make this happen? Thanks
1
10819
by: Andy Rose | last post by:
..Hi all, I want to catch an 'enter' keypress event on a web form and submit the form as if a button had been clicked rather than the default post back behaviour. I know the following javascript can be placed in the body tag to do this. onkeydown="if(event.keyCode == 13){document.getElementById('iBtnSubmit').onClick(); This will work fine if 'iBtnSubmit' is an input type of 'Button' but the
41
4326
by: JohnR | last post by:
In it's simplest form, assume that I have created a usercontrol, WSToolBarButton that contains a button. I would like to eventually create copies of WSToolBarButton dynamically at run time based on some initialization information obtained elsewhere. Basically, I'm going to create my own dynamic toolbar where the toolbarbuttons can change. I'm not using the VB toolbar because of limitations in changing things like backcolor (I can't get...
3
1618
by: LDD | last post by:
Hey folks I have some interesting behaviour going in. Inside a form, I download some data. The form is used to show the status, and set button states etc... I have a break point set up at one of the button click event handlers. When the button is clicked, the application doesn't stop at the breakpoint for the click event. Nor does it stop at any of the other breakpoints.
2
1362
by: Sunny | last post by:
Hi, I have an application using IE6 before and now we have upgraded to IE7. After upgrading, I have been having issues with button click event when embedded JavaScript file into the page. Removing the embeded java scrip file makes my button fire the click event again. Does anyone has the same problem? If so, what is the solution for it? Sunny
0
10109
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10051
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9916
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8939
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7464
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5486
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4017
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2853
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.