Hi....I know this might be a simple query, but its troubling me a lot.
I have Form 1 with a button on it, I'm trying to open another form (Form 2) with that button click.
I have created an instance of this form and then I used Show() function.
While Executing, When I click the button, the form 2 is displayed, I closed it and then again clicked the button, at this point, it gave me an Error " Cannot Access a Disposed Object ".
Everytime, I have to close the application and then execute it again.
Please Help, I'm stuck.
Cannot Access a Disposed Object
Page 1 of 12 Replies - 3531 Views - Last Post: 31 May 2010 - 08:17 AM
Replies To: Cannot Access a Disposed Object
#2
Re: Cannot Access a Disposed Object
Posted 30 May 2010 - 11:36 PM
Please show us your Code. I think you are using the same instance every time.
Be sure to create a new Instance everytime you call the Show() Function.
Be sure to create a new Instance everytime you call the Show() Function.
#3
Re: Cannot Access a Disposed Object
Posted 31 May 2010 - 08:17 AM
Hi, My Problem is solved.....
Actually I was declaring the variable before the button click event
Dim ab As New CompanyClientDetails
Private Sub CompanyClientDetailsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CompanyClientDetailsToolStripMenuItem.Click
ab.Show()
End Sub
Then I declared it inside the click event
Private Sub CompanyClientDetailsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CompanyClientDetailsToolStripMenuItem.Click
Dim ab As New CompanyClientDetails
ab.Show()
End Sub
And it worked fine.....
Thanx.............
Actually I was declaring the variable before the button click event
Dim ab As New CompanyClientDetails
Private Sub CompanyClientDetailsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CompanyClientDetailsToolStripMenuItem.Click
ab.Show()
End Sub
Then I declared it inside the click event
Private Sub CompanyClientDetailsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CompanyClientDetailsToolStripMenuItem.Click
Dim ab As New CompanyClientDetails
ab.Show()
End Sub
And it worked fine.....
Thanx.............
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|