How to associate two windows forms?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Developer111
    New Member
    • Apr 2010
    • 28

    #1

    How to associate two windows forms?

    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.
  • Joseph Martell
    Recognized Expert New Member
    • Jan 2010
    • 198

    #2
    The easiest way is to tell your main form that there is an error and let your main form bring up the error form using ShowDialog()

    As a second option, you can let whatever object is executing your logic in the background handle your main form's Activated event:

    Code:
    AddHandler Me.Activated, AddressOf myWorker.FocusHandler
    That way any time the main form is clicked on and an error form is active you can immediately give focus back to your error form using

    Code:
    If Not (errorForm Is Nothing) Then
        errorForm.Focus()
    End If
    or something like that.

    Comment

    Working...