Vitaly
Mon Mar 01 01:31:57 CST 2004
It's really helps!
Thank you!
Vitaly Sedov
"Igor Zinkovsky [MSFT]" <igor_vsbuildlab@online.microsoft.com> wrote in
message news:7F738A73-2910-467F-9981-DF6BDDD1F9D1@microsoft.com...
> Hi Vitaly.
>
> It looks like the AfterSelect event handler is trying to call
CreateHandle() on the TreeView object after it has been disposed by
this.Close().
>
> You should inherit your own tree from TreeView Class, and override
CreateHandle() method of that class to not call the base method if the
object has already been disposed:
>
> public class myTree : System.Windows.Forms.TreeView
> {
> protected override void CreateHandle()
> {
> if(!this.IsDisposed)
> base.CreateHandle ();
> }
> }
>
> Hope this helps,
> Igor Zinkovsky
> Visual Studio Build/Release Team
>
> This posting is provided "AS IS" with no warranties, and confers no
rights. Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
>
> ----- Vitaly Sedov wrote: -----
>
> Hi All!
>
> I have an application that opens form with TreeView.
> I want to close form by AfterSelect Event:
>
> private void MyTreeView_AfterSelect(object sender,
> System.Windows.Forms.TreeViewEventArgs e)
> {
> this.Close();
> }
>
> But everytime when I clicking on TreeView Item,
> I get following error:
>
> An unhandled exception of type 'System.ObjectDisposedException'
occurred in
> system.windows.forms.dll
> Additional information: Cannot access a disposed object named
"TreeView".
>
> Any ideas?
>
> Thank you,
> Vitaly Sedov
>
>
>