Link to home
Start Free TrialLog in
Avatar of Ramesh Srinivas
Ramesh SrinivasFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Datagrid refresh problem... well... kinda...

Hello,

I am receiving an error telling me that i cannot open an already disposed form.

The strange thing is that the form (which is said to be disposed) is open.

The steps which lead to this error are:


1) Open Main Form
2) Open Form1
3) Close Form1
4) Open Form1
5) Open Form2 from Form1
6) Raise an event in Form1 from Form2

If I edit out the line which raises the event in Form1 - I do not get the error.

So what am I doing wrong with regards to raising the event???


Step 6) The code to raise event is:

Mod_Form1.RaiseEditRecordInserted()


Form1's Module code contains:

Public Event EditRecordInserted()
    Public Sub RaiseEditRecordInserted()
        RaiseEvent EditRecordInserted()
End Sub

Form1's load event has:

AddHandler Mod_Edit.EditRecordInserted, AddressOf HandleRecordInserted

And then there's the actual sub which is:

Public Sub HandleRecordInserted()
        fetchGridData(0)
End Sub


Any help appreciated - thanks.

KS
ASKER CERTIFIED SOLUTION
Avatar of angelfeijoo
angelfeijoo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ramesh Srinivas

ASKER

It should execute every time the form1 opens because it is in the form_load event.
Avatar of angelfeijoo
angelfeijoo

Where do you assign value to Mod_Form1 ?
Seems that you were right I guess.

What I did was to put a RemoveHandler into the form1_Closing event.

Looks like its working now.

cheers,

KS