Solved

Validation in MDI Application

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

It seems a simple enough task, yet I see repeated questions asking how to do it: how to pass data between two forms. In this article, I will show you the different mechanisms available for you to do just that. This article is directed towards the .N…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

14 Experts available now in Live!

Get 1:1 Help Now