Ramesh Srinivas
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.RaiseEditRecordI nserted()
Form1's Module code contains:
Public Event EditRecordInserted()
Public Sub RaiseEditRecordInserted()
RaiseEvent EditRecordInserted()
End Sub
Form1's load event has:
AddHandler Mod_Edit.EditRecordInserte d, AddressOf HandleRecordInserted
And then there's the actual sub which is:
Public Sub HandleRecordInserted()
fetchGridData(0)
End Sub
Any help appreciated - thanks.
KS
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.RaiseEditRecordI
Form1's Module code contains:
Public Event EditRecordInserted()
Public Sub RaiseEditRecordInserted()
RaiseEvent EditRecordInserted()
End Sub
Form1's load event has:
AddHandler Mod_Edit.EditRecordInserte
And then there's the actual sub which is:
Public Sub HandleRecordInserted()
fetchGridData(0)
End Sub
Any help appreciated - thanks.
KS
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Where do you assign value to Mod_Form1 ?
ASKER
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
What I did was to put a RemoveHandler into the form1_Closing event.
Looks like its working now.
cheers,
KS
ASKER