Use the form that I add an my project
I added a form from another solution.(With right on my solution and clicked add existing item and then select a resent form with name "newForm.cs").Then this form with own objects added to my project.But I can't use this form in my code.For example I want to show this form.But it isn't in my solution as a class that I use:"newForm frm = new newForm". How do I c开发者_JS百科an add this form that I can use it as a class. I hope I have made the correct question. Thanks very much.
If you want to set this as startup form then Edit that from the program.cs file
Moreover might be you need to change the namespace of the added form, please check that.
If you want to start this form from other form then create an object of this form and show the instace of this form.
Formname frm1 = new Formname();
frm1.show();
If you are showing this from some Already existing form then you simply create a new object of the Form like:
Form2 frm = new Form2();
//set other properties
frm.Show();
if you want it to be Startup form then in the Program.cs Change the Form in Application.Run to
Application.Run(new Form2());
Update
Ok i checked there can be Problem of different Namespaces of the Both forms. You may need to Manually or Search and Replace the Namespace name to that of the Project.. (usually its the name of the project.. check with other Forms of the Project).
OR you can include that Form's Namespace by use of using
keyword in your code.
精彩评论