gchq
Well-known member
- Joined
- Dec 14, 2007
- Messages
- 168
- Programming Experience
- 10+
When a tab panel is loading I have the following lines of code
On rare occasions it will throw an error
Cannot access a disposed object.
Object name: 'SS_Label'.
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.ControlCollection.Add(Control value)
Any idea where I should be looking? As you can see I am testing to see if it exists (or creating a new control) before adding it..
=====================================================
Added 16:08 UTC
I was under the impression that once an object was disposed of, it was set to nothing - clearly that is not the case
If there any way I can check for IsDisposed within the New() Sub in my Custom Control Class?
VB.NET:
If MainSS Is Nothing Then
MainSS = New CustomControl.SS_Label
End If
TabPanel.Controls.Add(MainSS)
On rare occasions it will throw an error
Cannot access a disposed object.
Object name: 'SS_Label'.
at System.Windows.Forms.Control.CreateHandle()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.ControlCollection.Add(Control value)
Any idea where I should be looking? As you can see I am testing to see if it exists (or creating a new control) before adding it..
=====================================================
Added 16:08 UTC
I was under the impression that once an object was disposed of, it was set to nothing - clearly that is not the case
If there any way I can check for IsDisposed within the New() Sub in my Custom Control Class?
Last edited: