Solved

Validation in MDI Application

Posted on 2004-09-04
7
229 Views
Last Modified: 2009-07-29
In my MDI Application, I have an MDI Parent Form which contains two
Child Forms, childA and childB. childA has a TextBox which has an
Validating event Handler

When the Users enters some text into this TextBox which does not pass
the validating event, the Event Handler sets the Cancel Property of
the CancelEventArgs argument to TRUE. The Cursor cannot leave the
Texbox, which is excty what I want... but:

When the user clicks on another MDI Child (e.g. childB), childB comes
to front. The user can click on any Textbox on childB, he will not get
the cursor into the Textbox, because the Cursor is held back in
childA. The user thinks that the Application is not responding.

It would be a lot better if I could prevent the User from activating
childB as long as childA has Validation Errors.

I am looking for a "clean" solution of this problem.

Regards
Matthias
0
Comment
Question by:MattHess
  • 3
7 Comments
 
LVL 19

Expert Comment

by:arif_eqbal
ID: 11987358
Well there's a hitch here, if you keep him stuck on the textbox he will not be able to do anything else with your application, So there's no direct way of doing it. Anyway, What you can do is set the form where you have the TextBox to TopMost on the validating Event Handler in case the validation fails, and again set it back to normal if it passes the validation.

However the focus can still pass to the second child form but since this form will be topmost he can probably undersatand that he needs to finish that job first.

If you want to be still more strict you can send back the focus to this form on the MdiChildActivate event of the MDI or the Activate event of the second child form. You'll have to keep a reference as to which form is being validated, you can do that in a module level variable....


0
 
LVL 8

Expert Comment

by:gregasm
ID: 11998061
What about implementing the ChildA as a modal dialog? This lets the user know that he *must* finish with ChildA before he can do anything else.
0
 

Author Comment

by:MattHess
ID: 11999455
Hello everyone

Thanks for your comments and ideas. Here arem y thoughts:

"if you keep him stuck on the textbox he will not be able to do anything else with your application"
... I would only use the Validating / Validated mechanism for field level validation. It simply makes no sense to let the user enter '32-12-2004' into a date field, does it? The user would have to go back and change the date to something meaningful.

I tried the TopMost Property. Does not work at all with MDI (at least in my tests).

I also tried the MDIChildActivate event, but it did not work eighter.

Child A as a modal dialog is also not an option. We definitely want to stick with MDI.

Regards Matthias
0
 
LVL 8

Accepted Solution

by:
gregasm earned 500 total points
ID: 11999500
0
 
LVL 8

Expert Comment

by:gregasm
ID: 11999586
http://www.dotnet247.com/247reference/msgs/53/268424.aspx

The keyword is "clean" solution for this problem, as you mentioned above.

I have found myself facing the same problem as you several times in the past, and of all my solutions, none of them are what I consider "clean"...
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Flash (http://en.wikipedia.org/wiki/Adobe_Flash) has evolved over the years to where it has become a masterful tool for displaying content screen.  It has excellent layout placement, UI precision as well as rendering capabilities. This, along with t…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question