473,396 Members | 1,929 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,396 software developers and data experts.

Suppress focus events of a textbox control in Validating event

Hello

I have a Data Entry Form having some controls including a TextBox. When the
user types an entry, I query a table and if it was entered before, I ask the
user (using ShowModal method of a custom message form) if he wants to see
his old entry in a new form. if he/she choose Yes, I create a new form and
show the previously entered data in it.

The problem is when I create and show the new form, the validating event is
fired two times and so it asks again if the user wants to see previously
entered data.
The application is an MDI application.

Please help me what am I wrong with.
Regards
Hamed
Jun 9 '07 #1
3 1952

"Hamed" <ha***@raymehr.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Hello

I have a Data Entry Form having some controls including a TextBox. When
the user types an entry, I query a table and if it was entered before, I
ask the user (using ShowModal method of a custom message form) if he wants
to see his old entry in a new form. if he/she choose Yes, I create a new
form and show the previously entered data in it.

The problem is when I create and show the new form, the is fired two times
and so it asks again if the user wants to see previously entered data.
The application is an MDI application.

Please help me what am I wrong with.
Why don't you pass a local scope Boolean flag in the form's constructor, and
at the validating event check the flag, if the Boolean flag is true bypass
code/exit or else execute the code and exit?

Jun 9 '07 #2
The Validating event of the first form is fired twice not the second form.

I think there is some interference between focus events and ShowModal
method.

Please help. Am I wrong in using the Validating routines?

Hamed

Why don't you pass a local scope Boolean flag in the form's constructor,
and at the validating event check the flag, if the Boolean flag is true
bypass code/exit or else execute the code and exit?

Jun 9 '07 #3

"Hamed" <ha***@raymehr.comwrote in message
news:O$**************@TK2MSFTNGP02.phx.gbl...
The Validating event of the first form is fired twice not the second form.
Well, you should still be able to set some kind of flag there too. Maybe
some flag in a Global scope.

It's the same thing with having Textbox_Change event firer on a Form_load
where you have code in the TextBox_Change event, and you only want the code
in the event to executed when the user changes data in the Textbox.

You don't want the Textbox_Change event to firer on the Form_Load and
execute code because you populated default data in the TextBox.Text =
"MM/DD/YYYY", as an example for display purpose, which will make the
Textbox_Change event firer and code executed if you do bypass it during the
Form_Load.

You simply avoid the situation by setting a gbBoolen flag to true to make it
bypass the code in the Event and set it to false at the end of the Form_Load
to make the event execute the code when it's fired due to the user changing
data in the TextBox.

It's the same principles here. You know the conditions as to when this is
happening so set a Global Boolean flag, if you must, to true and bypass
code execution and set it to false when the method is exited.
Jun 9 '07 #4

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

Similar topics

6
by: Patrick De Ridder | last post by:
How do I connect to an event being thrown when a field has lost focus? Could you please give a code example? -- Patrick De Ridder ngmail@freeler.nl
1
by: seash | last post by:
Is there any way to suppress an event method? i got Enter & leave Events on two groupBoxs, they r " private void groupBox1_Enter(object sender, System.EventArgs e)" and private void...
0
by: Miquel | last post by:
Hi all. I felt frustrated when developing an 'UserControl' derivated from textBox, because sequence event (and Validate event) seems to fail. I Always thought my code was wrong. But after...
0
by: Matthew | last post by:
All, I have searched google and the newsgroups but can't find anything the same as what I am experiencing (though I may have missed something). I have controls (textboxes) within UserControls...
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...
7
by: Bruce HS | last post by:
I'd like to call my ancestor Validation Function every time any control on a Win Form generates a Validating or Validated event. I'm using VB. I've extended Textbox, for instance, to have its...
3
by: Patrick [MSFT] | last post by:
Let me preface this with the goal I'm trying to achieve is mimic a feature of another language (Dexterity used by Microsoft Dynamics) and so while a filling a drop down list is a workable solution...
3
by: Hamed | last post by:
Hello I have a Data Entry Form having some controls including a TextBox. When the user types an entry, I query a table and if it was entered before, I ask the user (using ShowModal method of a...
2
by: Jonathan N. Little | last post by:
As part of a JavaScript precheck form validation I noticed a problem with trying to return focus to the field with an error. I have setup a demo page. ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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,...

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.