473,413 Members | 1,718 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,413 software developers and data experts.

TextBox Leave Event fires, but not every time

After a user enters data into a field, I need to populate other controls on
the form, based on the user entry. I have to use either Leave, Validating or
Validated, and I take it I can't use LostFocus because there is no selection
for that event in the dropdown list on the code page. What's happening is
that all 3 events mentioned above for the textbox control fire in the proper
order when the form is invoked, but don't fire the first time I tab or mouse
out of the textbox. After that, they fire on cue.

I am invoking a child form from an MDIForm. I have several controls on the
child form (Form1), but this concerns a textbox (TB0) with a TabIndex of 0.
I invoke the form from the MDIForm with the following code:

Form1= New Form1()
Form1.MdiParent = Me
Form1.PARENTFRM = Me
Form1.Show()

In a step-through, I see that the Leave Event for the TB0 fires when the
last line of the above code executes (not sure why Another TextBox on the
form with a coded Leave Event doesn't fire at this point, even if I set it's
TabIndex to 0, and TB0 to 1.) When the form opens, focus is on TB0. I enter
data, then tab or mouse out to another TextBox (TB1), whose TabIndex=1 and
CausesValidation=True. No Leave Event fires on TB0. However, when I
Shift-Tab or mouse back into TB0, then tab or mouse out again, the Leave
Event on TB0 does fire. The event will fire for as long as I have the form
open, but the only important instance (the first one) of the event is
skipped! I can't expect users to tab out of and back into a field, so I'm
pretty much stuck.

Help. Please.

JD
Jul 22 '05 #1
2 6103
Hi Jaydee,

You might want to try setting focus to a different control and then back
again to tb0 inside the form's load event, simulating the click out and
click back in.

HTH,

Bernie Yaeger

"JayDee" <Ja****@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
After a user enters data into a field, I need to populate other controls
on
the form, based on the user entry. I have to use either Leave, Validating
or
Validated, and I take it I can't use LostFocus because there is no
selection
for that event in the dropdown list on the code page. What's happening is
that all 3 events mentioned above for the textbox control fire in the
proper
order when the form is invoked, but don't fire the first time I tab or
mouse
out of the textbox. After that, they fire on cue.

I am invoking a child form from an MDIForm. I have several controls on
the
child form (Form1), but this concerns a textbox (TB0) with a TabIndex of
0.
I invoke the form from the MDIForm with the following code:

Form1= New Form1()
Form1.MdiParent = Me
Form1.PARENTFRM = Me
Form1.Show()

In a step-through, I see that the Leave Event for the TB0 fires when the
last line of the above code executes (not sure why Another TextBox on the
form with a coded Leave Event doesn't fire at this point, even if I set
it's
TabIndex to 0, and TB0 to 1.) When the form opens, focus is on TB0. I
enter
data, then tab or mouse out to another TextBox (TB1), whose TabIndex=1 and
CausesValidation=True. No Leave Event fires on TB0. However, when I
Shift-Tab or mouse back into TB0, then tab or mouse out again, the Leave
Event on TB0 does fire. The event will fire for as long as I have the
form
open, but the only important instance (the first one) of the event is
skipped! I can't expect users to tab out of and back into a field, so I'm
pretty much stuck.

Help. Please.

JD

Jul 22 '05 #2
Thank you Bernie, your suggestion pointed me in the right direction.
Switching the focus back and forth did work, but not in the form's load
event. I put it in the MDI form's menu click event, after the child form's
Show() event is called. That worked fine. Thanks a lot for your help.

"Bernie Yaeger" wrote:
Hi Jaydee,

You might want to try setting focus to a different control and then back
again to tb0 inside the form's load event, simulating the click out and
click back in.

HTH,

Bernie Yaeger

"JayDee" <Ja****@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
After a user enters data into a field, I need to populate other controls
on
the form, based on the user entry. I have to use either Leave, Validating
or
Validated, and I take it I can't use LostFocus because there is no
selection
for that event in the dropdown list on the code page. What's happening is
that all 3 events mentioned above for the textbox control fire in the
proper
order when the form is invoked, but don't fire the first time I tab or
mouse
out of the textbox. After that, they fire on cue.

I am invoking a child form from an MDIForm. I have several controls on
the
child form (Form1), but this concerns a textbox (TB0) with a TabIndex of
0.
I invoke the form from the MDIForm with the following code:

Form1= New Form1()
Form1.MdiParent = Me
Form1.PARENTFRM = Me
Form1.Show()

In a step-through, I see that the Leave Event for the TB0 fires when the
last line of the above code executes (not sure why Another TextBox on the
form with a coded Leave Event doesn't fire at this point, even if I set
it's
TabIndex to 0, and TB0 to 1.) When the form opens, focus is on TB0. I
enter
data, then tab or mouse out to another TextBox (TB1), whose TabIndex=1 and
CausesValidation=True. No Leave Event fires on TB0. However, when I
Shift-Tab or mouse back into TB0, then tab or mouse out again, the Leave
Event on TB0 does fire. The event will fire for as long as I have the
form
open, but the only important instance (the first one) of the event is
skipped! I can't expect users to tab out of and back into a field, so I'm
pretty much stuck.

Help. Please.

JD


Jul 22 '05 #3

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

Similar topics

1
by: Chris Mayers | last post by:
Hi, I have an application that has (for the sake of argument) 2 (MDI) windows open. If I click into a textbox on FormA then the 'Enter' event for that TextBox fires, great! However, if I then...
5
by: Maxine G | last post by:
I have two forms, a menu and a data entry form. The entry form is bound to a query against linked SQL server tables. In the deactivate event, I have some code which asks the user if they want to...
2
by: MrNobody | last post by:
I notice that if you use the TextChanged event on a TextBox it will fire for every single change, like appending a single character- even if the user continues to type. I was wondering if there...
7
by: Itar | last post by:
I'm having a problem supressing characters in a text box. I only want alpha numeric characters (no special chars). I can handle the TextBox_KeyPress event to supress the invalid characters when...
4
by: miss_kait | last post by:
I would like to emulate the afterupdate event in vb.net after scanning a barcode. I have multiple barcodes to scan and after each scan I would like focus to move to the next text box. I have...
10
by: Dennis | last post by:
I have a simple form with one button and one text box. In the Form, I create an array list to track the events by adding a descriptive string item to the arraylist in each event. I first Click on...
2
by: JayDee | last post by:
After a user enters data into a field, I need to populate other controls on the form, based on the user entry. I have to use either Leave, Validating or Validated, and I take it I can't use...
14
by: teddysnips | last post by:
WINDOWS FORMS I've a form that has a textbox that allows the user to enter a string. On the LostFocus event, the textbox formats the string into a preferred format. However, if the user...
2
by: jd | last post by:
I have several textboxes in which the end user can enter values. When the user presses the Enter key when in any of the textboxes, or leaves that textbox, I want a routine to run (mathematical...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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...
0
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.