|
ms
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to make a form of main application reuseable by others?Hi, I'm using vs2005, .net 2.0, Win2k server for a Windows applcaiton. I
have a main application where there is a a form and the codes that I would like to make it reuseable by other applications. 1. I already have a classlibray project but I don't think I can include a "form" in it, right? 2. So, do I make this form into a dll so other application can include it as a reference? 3. To do the item 2, does that mean that I would create a new project and add the form and the code in it. But how to specify to generate a dll instead of a project that produce .exe file after it's compiled? Thank you. -- Thanks. Pucca,
You can definitely include a form in a class library. A form is nothing more than a class. All you have to do is make sure the form is public. You might want to consider whether or not there are menus on the form, if it is used as a child form, then it will not take to nicely, depending on how menus on the parent form are used. All you have to do is create a "Class Library" project and then you can add your form code to it, and then reference it from other applications. Hope this helps. -- Show quoteHide quote- Nicholas Paldino [.NET/C# MVP] - mvp@spam.guard.caspershouse.com "Pucca" <Pu***@discussions.microsoft.com> wrote in message news:BC86FAB9-553A-4E23-8DCD-7355CDA456CC@microsoft.com... > Hi, I'm using vs2005, .net 2.0, Win2k server for a Windows applcaiton. I > have a main application where there is a a form and the codes that I would > like to make it reuseable by other applications. > 1. I already have a classlibray project but I don't think I can include > a > "form" in it, right? > 2. So, do I make this form into a dll so other application can include it > as a reference? > 3. To do the item 2, does that mean that I would create a new project and > add the form and the code in it. But how to specify to generate a dll > instead of a project that produce .exe file after it's compiled? > Thank you. > -- > Thanks. Yes a form is simply a class that has derived from the "Form" class.
This form can be duplicated as many times as you want by creating multiple instances of the class. Once your form is declared "public" then your other applications can link to the DLL as a reference and use it in: MyForm myForm = new MyForm(); MyForm.ShowDialog(); or Application.Run(new MyForm()); both of which work well. But the latter is used for initiating the MAIN form only while the former may be used to show an independent form. Remember that to change from "exe" to "dll" simply change the application type from Windows Application to Class Library in the project properties part. Freiddie http://fei.yuanbw.googlepages.com/ http://freiddy.blogspot.com/ http://crazibe.blogspot.com/ Thank you both for the help. I will now try to do that.
-- Show quoteHide quoteThanks. "Nicholas Paldino [.NET/C# MVP]" wrote: > Pucca, > > You can definitely include a form in a class library. A form is nothing > more than a class. All you have to do is make sure the form is public. You > might want to consider whether or not there are menus on the form, if it is > used as a child form, then it will not take to nicely, depending on how > menus on the parent form are used. > > All you have to do is create a "Class Library" project and then you can > add your form code to it, and then reference it from other applications. > > Hope this helps. > > > -- > - Nicholas Paldino [.NET/C# MVP] > - mvp@spam.guard.caspershouse.com > > > "Pucca" <Pu***@discussions.microsoft.com> wrote in message > news:BC86FAB9-553A-4E23-8DCD-7355CDA456CC@microsoft.com... > > Hi, I'm using vs2005, .net 2.0, Win2k server for a Windows applcaiton. I > > have a main application where there is a a form and the codes that I would > > like to make it reuseable by other applications. > > 1. I already have a classlibray project but I don't think I can include > > a > > "form" in it, right? > > 2. So, do I make this form into a dll so other application can include it > > as a reference? > > 3. To do the item 2, does that mean that I would create a new project and > > add the form and the code in it. But how to specify to generate a dll > > instead of a project that produce .exe file after it's compiled? > > Thank you. > > -- > > Thanks. > > >
Other interesting topics
Pressing Enter on ListBox should invoke DoubleClick
how to do a call back between forms Why public method in internal class is allowed Login failed SQL Express interface to web service .NET Remoting, Event Subscription to the Remoting Object / Subscribed event does not fire... Cool Interview questions for dot net developers Page load vs. reload ? double or single \\ in config file Trapping key sequences from anywhere in an app |
|||||||||||||||||||||||