473,768 Members | 1,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Click event gets lost when call MSGBOX in leave event

Tom
I have a VB .NET application that has a text box with the
following code to handle the leave event.

Private Sub txtIDiscountRat e_TextChanged(B yVal sender
As System.Object, ByVal e As System.EventArg s) Handles
txtIDiscountRat e.Leave
If txtIDiscountRat e.Text.Trim <> "" AndAlso _
MsgBox("Are you sure you want to use a non-
default discount rate?", MsgBoxStyle.OKC ancel) _
= MsgBoxResult.Ca ncel Then
'txtIDiscountRa te.Text = ""
End If
End Sub

There are also several buttons on the same dialog box as
the text box. The problem occurs when I have focus on
the text box and then click on a button. If the call to
MSGBOX gets executed (because there is text in the
textbox) then the button click event never gets called.
(I have a breakpoint set on the first line of the button
click event routine.) I've checked (by commenting out
code) that it is definitely the call to MSGBOX which
makes the call to the button click routine get lost.

Suggestions please. Thanks
Nov 21 '05 #1
3 3850
You have it in the Text Changed Event. Change it to TextBox Lost Focus. See
below:

Lost Focus Event:
--------------------

Private Sub TextBox1_LostFo cus(ByVal sender As Object, ByVal e As
System.EventArg s) Handles TextBox1.LostFo cus
End Sub

You are using Text Changed/Lost Focus Events. See below:
------------------------------------------------------

Private Sub txtIDiscountRat e_TextChanged(B yVal sender ..., but you use
'Handles TextBox.LostFoc us

The above is a mistake.

Remember to use 'MessageBox.Sho w(...) now that you are you are using VB.NET.
Yes, of course you can still use the old VB 6 way.

"Tom" wrote:
I have a VB .NET application that has a text box with the
following code to handle the leave event.

Private Sub txtIDiscountRat e_TextChanged(B yVal sender
As System.Object, ByVal e As System.EventArg s) Handles
txtIDiscountRat e.Leave
If txtIDiscountRat e.Text.Trim <> "" AndAlso _
MsgBox("Are you sure you want to use a non-
default discount rate?", MsgBoxStyle.OKC ancel) _
= MsgBoxResult.Ca ncel Then
'txtIDiscountRa te.Text = ""
End If
End Sub

There are also several buttons on the same dialog box as
the text box. The problem occurs when I have focus on
the text box and then click on a button. If the call to
MSGBOX gets executed (because there is text in the
textbox) then the button click event never gets called.
(I have a breakpoint set on the first line of the button
click event routine.) I've checked (by commenting out
code) that it is definitely the call to MSGBOX which
makes the call to the button click routine get lost.

Suggestions please. Thanks

Nov 21 '05 #2
You have it in the Text Changed Event. Change it to TextBox Lost Focus. See
below:

Lost Focus Event:
--------------------

Private Sub TextBox1_LostFo cus(ByVal sender As Object, ByVal e As
System.EventArg s) Handles TextBox1.LostFo cus
End Sub

You are using Text Changed/Lost Focus Events. See below:
------------------------------------------------------

Private Sub txtIDiscountRat e_TextChanged(B yVal sender ..., but you use
'Handles TextBox.LostFoc us

The above is a mistake.

Remember to use 'MessageBox.Sho w(...) now that you are you are using VB.NET.
Yes, of course you can still use the old VB 6 way.

"Tom" wrote:
I have a VB .NET application that has a text box with the
following code to handle the leave event.

Private Sub txtIDiscountRat e_TextChanged(B yVal sender
As System.Object, ByVal e As System.EventArg s) Handles
txtIDiscountRat e.Leave
If txtIDiscountRat e.Text.Trim <> "" AndAlso _
MsgBox("Are you sure you want to use a non-
default discount rate?", MsgBoxStyle.OKC ancel) _
= MsgBoxResult.Ca ncel Then
'txtIDiscountRa te.Text = ""
End If
End Sub

There are also several buttons on the same dialog box as
the text box. The problem occurs when I have focus on
the text box and then click on a button. If the call to
MSGBOX gets executed (because there is text in the
textbox) then the button click event never gets called.
(I have a breakpoint set on the first line of the button
click event routine.) I've checked (by commenting out
code) that it is definitely the call to MSGBOX which
makes the call to the button click routine get lost.

Suggestions please. Thanks

Nov 21 '05 #3
You have it in the Text Changed Event. Change it to TextBox Lost Focus. See
below:

Lost Focus Event:
--------------------

Private Sub TextBox1_LostFo cus(ByVal sender As Object, ByVal e As
System.EventArg s) Handles TextBox1.LostFo cus
End Sub

You are using Text Changed/Lost Focus Events. See below:
------------------------------------------------------

Private Sub txtIDiscountRat e_TextChanged(B yVal sender ..., but you use
'Handles TextBox.LostFoc us

The above is a mistake.

Remember to use 'MessageBox.Sho w(...) now that you are you are using VB.NET.
Yes, of course you can still use the old VB 6 way.

"Tom" wrote:
I have a VB .NET application that has a text box with the
following code to handle the leave event.

Private Sub txtIDiscountRat e_TextChanged(B yVal sender
As System.Object, ByVal e As System.EventArg s) Handles
txtIDiscountRat e.Leave
If txtIDiscountRat e.Text.Trim <> "" AndAlso _
MsgBox("Are you sure you want to use a non-
default discount rate?", MsgBoxStyle.OKC ancel) _
= MsgBoxResult.Ca ncel Then
'txtIDiscountRa te.Text = ""
End If
End Sub

There are also several buttons on the same dialog box as
the text box. The problem occurs when I have focus on
the text box and then click on a button. If the call to
MSGBOX gets executed (because there is text in the
textbox) then the button click event never gets called.
(I have a breakpoint set on the first line of the button
click event routine.) I've checked (by commenting out
code) that it is definitely the call to MSGBOX which
makes the call to the button click routine get lost.

Suggestions please. Thanks

Nov 21 '05 #4

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

Similar topics

8
2035
by: George Hester | last post by:
In a page I have when the user left-clicks the page a Input box for a form gets the focus. But if the user right-clicks the page the Input box is not getting the focus. I'd like the Input box to get the focus no matter where on the page the user clicks be it right-click or left-click. Right now there is no context menu when the user right-clicks. Do you think that's the problem? Any ideas how to get this right-click left-click Input box...
1
14726
by: Sakharam Phapale | last post by:
Hi All, How to capture Mouse Single click and mouse double click event on Commnad Button. I am doing as follows. Private void Button1_MouseUp(Object sender, System.Windows.Forms.MouseEventArgs e) {
7
1382
by: Rich | last post by:
Hello, I have 10 textboxes on a form. I would like to validate text-data entry on each textbox. I was looking for a Form_Current event or Form_Change event but did not recognize any such events. Or maybe there is a property for the Textboxes where I can set data entry conditions? Wondering about CausesValidation textbox property-how to use.
3
1352
by: David Kelly | last post by:
I am noticing a strange behaviour with the button Click event. A simple test case - a form with a textbox and a button. Attach the following two handlers. Private Sub TextBox1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Leave MsgBox("leave") End Sub
12
7386
by: SJ | last post by:
Hope someone can help me out there I'm struggling with a particular problem... I have a form with many tab pages. On one tab page I've got a button which when clicked with a mouse adds items into a datagrid. When a user presses the enter key on this button I want the mouse click event to be activated but instead the tab page's validating event is called. I understand that this behaviour is by partly by design (Accept button etc) but I...
0
274
by: Tom | last post by:
I have a VB .NET application that has a text box with the following code to handle the leave event. Private Sub txtIDiscountRate_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtIDiscountRate.Leave If txtIDiscountRate.Text.Trim <> "" AndAlso _ MsgBox("Are you sure you want to use a non- default discount rate?", MsgBoxStyle.OKCancel) _ = MsgBoxResult.Cancel Then
4
3478
by: Winista | last post by:
I have a page with bunch of user controls and standard controls on the page. And then I have a Button control on the page which is used to save the data on server side. All was working fine and dandy till yesterday. Today the button click event started showing some weired behavior. Some time the code will not get into that handler. And I have tracked down the pattern when it is not working. I have 2 combo box controls on the page which...
2
7197
by: Joergen Bech | last post by:
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 ToolStripButtons.
1
4305
by: \Ji Zhou [MSFT]\ | last post by:
Hello Jason, Thanks for using Microsoft Newsgroup Support Service, my name is Ji Zhou and I will be working on this issue with you. I have tried to but cannot reproduce your issue on my side. From your codes, I think the logical is, every time the Timer's elapsed event fires, we call the Check_For_Version_Update() function. From the Check_For_Version_Update() function, we judge a condition statement, and determine whether to call...
0
9407
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10176
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9963
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
9844
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
8840
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...
0
5284
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5425
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3540
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2808
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.