|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Check if Component is not disposed?Hello:
I have written the following code in the main form close event procedure: If Not instfrmMain.rb1 Is Nothing Then instfrmMain.rb1.Checked = True But I still get an error from the JIT compiler that the rb1 component does not exist any more..ie. it is disposed..and I am trying to access its properties. How can we make sure that the component exists before any of its property is changed? Thanks Just because a component is disposed, does not meant that the variable that
points to it is Nothing. Disposing a component means calling its Dispose method - and that just runs some clean up code. It's not magic that sets everything that ever pointed to that object to point to nothing. If you want the variable to point to nothing after you dispose the object, then add a line of code to set it to Nothing. Show quoteHide quote "IdleBrain" <indianmostwan***@yahoo.com> wrote in message news:1147714456.836788.40920@v46g2000cwv.googlegroups.com... > Hello: > I have written the following code in the main form close event > procedure: > If Not instfrmMain.rb1 Is Nothing Then instfrmMain.rb1.Checked = True > > > But I still get an error from the JIT compiler that the rb1 component > does not exist any more..ie. it is disposed..and I am trying to access > its properties. > > How can we make sure that the component exists before any of its > property is changed? > > Thanks > Hai Marina,
I apologize for unable to explain my issue clearly.. I am trying to change the checked property of a radio button on closing the main form. But, I get an error from the JIT, sometimes, saying that the radio button that I am trying to access is disposed. Is there any method that I can use to check if a component is disposed? IdleBbrain,
Although there is the property control.IsDisposed. I don't understand why you want to change something in your window while it is closing. The eyes of humans are fare to slow to see that. Or do you want to cancel the closing before? Cor Show quoteHide quote "IdleBrain" <indianmostwan***@yahoo.com> schreef in bericht news:1147718269.878327.128130@u72g2000cwu.googlegroups.com... > Hai Marina, > I apologize for unable to explain my issue clearly.. > > I am trying to change the checked property of a radio button on closing > the main form. > But, I get an error from the JIT, sometimes, saying that the radio > button that I am trying to access is disposed. > > Is there any method that I can use to check if a component is disposed? > Hello Cor,
Whenever I make changes to the A/D card, I update its GUI part using subroutines. When the form is being closed, I want to use the same subroutine to reset the A/D card voltages too..thats when this problem arises. Conrol.IsDisposed seems to be working good. I knew something like this one existed. I still wonder why the intellisense help does not indicate the IsDisposed method? Thank you very much.. Hello Cor,
Whenever I make changes to the A/D card, I update its GUI part using subroutines. When the form is being closed, I want to use the same subroutine to reset the A/D card voltages too..thats when this problem arises. Conrol.IsDisposed seems to be working good. I knew something like this one existed. I still wonder why the intellisense help does not indicate the IsDisposed method? Thank you very much.. IdleBrain,
> I still wonder why the intellisense help does not indicate the Nobody does that, but it is placed in the complex members of control which > IsDisposed method? are not standard showed in intellisense. (You can set it in the properties from the IDE to show it). In VS 2005 it is a tab. Cor Hi,
Why dont you use the closing event instead? The form closing can be cancel so the control still exist. Ken ----------------------- Show quoteHide quote "IdleBrain" wrote: > Hello: > I have written the following code in the main form close event > procedure: > If Not instfrmMain.rb1 Is Nothing Then instfrmMain.rb1.Checked = True > > > But I still get an error from the JIT compiler that the rb1 component > does not exist any more..ie. it is disposed..and I am trying to access > its properties. > > How can we make sure that the component exists before any of its > property is changed? > > Thanks > > Hello Ken,
I tried using Closing() event instead of Closed() but the problem still exists. Its hard to check on when JIT would dispose unused components I guess.. Any other suggestions? |
|||||||||||||||||||||||