Plzzzzzzzzzzzzzzzzzzzzzzzzzz Help in form closing
-
Hi! i want to close windows form when i click on any tree node. when i click a tree node, after_select event of tree node is called and in that After_select event i closed my current web form and opened new form but it throws following exception. Disposed object of tree view could not be found. I posted this question two times before also but no satisfactory answer is given. One of member suggested to use IDisposal but i m not getting how to use it. So, can anyone suggest me the solution in detailed form. Thanx
-
Hi! i want to close windows form when i click on any tree node. when i click a tree node, after_select event of tree node is called and in that After_select event i closed my current web form and opened new form but it throws following exception. Disposed object of tree view could not be found. I posted this question two times before also but no satisfactory answer is given. One of member suggested to use IDisposal but i m not getting how to use it. So, can anyone suggest me the solution in detailed form. Thanx
EEmaan wrote:
One of member suggested to use IDisposal but i m not getting how to use it
IDisposable won't help here, the issue is precisely that you close the form while some code is running, and so the control is disposed while you're trying to use it. You're closing web forms ? Not windows forms ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
EEmaan wrote:
One of member suggested to use IDisposal but i m not getting how to use it
IDisposable won't help here, the issue is precisely that you close the form while some code is running, and so the control is disposed while you're trying to use it. You're closing web forms ? Not windows forms ?
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
Sorry i wrote Web Form instead of Windows form. Actually i m closing windows form by using this.close(); my piece of code is like private void TreeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) { Form2 f=new Form2(); f.show(); this.close(); } now plz give me its solution also.
-
Sorry i wrote Web Form instead of Windows form. Actually i m closing windows form by using this.close(); my piece of code is like private void TreeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) { Form2 f=new Form2(); f.show(); this.close(); } now plz give me its solution also.
I do not know the exact solution: But, see if this helps U. Locate the line "Application.Run(new Form1());" and enclose it within try catch. try { Application.Run(new Form1()); } catch(Exception exe) { }
Regards, Arun Kumar.A
-
Sorry i wrote Web Form instead of Windows form. Actually i m closing windows form by using this.close(); my piece of code is like private void TreeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) { Form2 f=new Form2(); f.show(); this.close(); } now plz give me its solution also.
OK, I remember this. I told you days ago what to do. You can't do this. Because, when you close this form, you cause the Form2 instance to also be closed/disposed. Instead, make form1 and form2 user controls, put them both on the one form, and switch between them. Also, for goodness sakes, use real variable names and not TreeView1 and Form2.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
I do not know the exact solution: But, see if this helps U. Locate the line "Application.Run(new Form1());" and enclose it within try catch. try { Application.Run(new Form1()); } catch(Exception exe) { }
Regards, Arun Kumar.A
Gosh - it's pretty obvious what's going wrong.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
OK, I remember this. I told you days ago what to do. You can't do this. Because, when you close this form, you cause the Form2 instance to also be closed/disposed. Instead, make form1 and form2 user controls, put them both on the one form, and switch between them. Also, for goodness sakes, use real variable names and not TreeView1 and Form2.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
sorry i m not getting u if u can please follow the following link MBR IT-_NET 247 TreeView and ObjectDisposedException on microsoft_public_dotnet_framework_windowsforms.htm its seems that it is giving me the exact solution of my problem .I did it also but ite not working. Can u guide after viewing this page that what to do. Thanx alot for ur replies
-
sorry i m not getting u if u can please follow the following link MBR IT-_NET 247 TreeView and ObjectDisposedException on microsoft_public_dotnet_framework_windowsforms.htm its seems that it is giving me the exact solution of my problem .I did it also but ite not working. Can u guide after viewing this page that what to do. Thanx alot for ur replies
That's not a link. What the page you hoped to link to says does not matter. What you're doing is wrong. Create user controls, lay them out to be your two forms. Put them both on the one form, and then make only one of them visible at a time.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
Sorry i wrote Web Form instead of Windows form. Actually i m closing windows form by using this.close(); my piece of code is like private void TreeView1_AfterSelect(object sender, System.Windows.Forms.TreeViewEventArgs e) { Form2 f=new Form2(); f.show(); this.close(); } now plz give me its solution also.
EEmaan wrote:
Form2 f=new Form2();
You are creating this object within the original form (where the TreeView1 is)... it is available only within the After_Select event. When you close a form, all objects that are part of that form are destroyed and references to those will no longer be valid. Hope this helps.