Solved

Validation in MDI Application

Posted on 2004-09-04
7
228 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now