Solved

Validation in MDI Application

Posted on 2004-09-04
7
230 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

Title # Comments Views Activity
How to share My.Settings in multiple application instances ? 7 76
Regarding swagger API 1 57
Data organization issue 7 54
Removing Version of .NET in Windows 10 17 108
The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

738 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