I have tow forms(form1,form2) and want to show form2 from form1 as dialog form and hide form1 while form2 is shown. It seems easy:
Code:
dim frm as form=new form2
Me.Hide
frm.ShowDialog
BUT, the problem is that form2 takes quite a long time to load cause its filled up with lots of controls, so if i use the above method form1 will hide immediately and leaves the user wondering what has happened to the program. I can think of two solutions:
First: Change the windows(not the application) cursor to 'waitcursor' to show the user that something is happening (I really dont know how ).

Second: Hide form1 when form2 load is finished. In order to do this i put the following code in the from2_load sub:

Code:
 Private Sub from2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
...
    Me.ParentForm.ActiveForm.Hide()
End Sub
or as an alternative:

Code:
 Private Sub from2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
...
   dim frm as Form=form2.ActiveForm
   frm.Hide()
End Sub
Both methods work but they stop RANDOMLY !!! with the error : Object Refrence not set to an instance .....

Whats wrong with it? and if it is totaly wrong why it does not make error every time?