Question How to associate two windows forms?

Developer111

Member
Joined
Apr 21, 2010
Messages
24
Programming Experience
5-10
In my VS-2008 (VB.Net) application, I am using a background worker to make my main form more responsive. In case of any error (in DoWork event) I m displaying the error on another form. In this case main form can’t be a parent of error form so if main form is clicked, error form go in the background (behind main form). I want to restrict the user to interact with the main form while error form is appearing. Is there any way to associate these two forms such that error form always appear in front of main form.

Thanks in advance.
 
Form.Owner Property (System.Windows.Forms)
Owned forms are also never displayed behind their owner form.
What you should do from the worker thread is to Invoke to UI thread (main form) and make the error window owned by main form. You still have to disable the (parts of) main form to restrict interaction. I'm guessing here that worker continues when there is errors, if not the error should be passed as result of the background operation. Instead of invoking directly you can also use the ReportProgress feature to pass on error info to main thread.
 
Back
Top