开发者

c# displaying form in class library winforms

开发者 https://www.devze.com 2023-02-19 20:44 出处:网络
I\'ve been given some code that is in effect a class library with a Winform module.Obviously I cannot run the class library directly.

I've been given some code that is in effect a class library with a Winform module. Obviously I cannot run the class library directly.

Is there anyway that I can 'run' it so that I can see what the form will look like when run? 开发者_开发技巧I need to check anchoring/docking, etc?

Thanks


Make a new WinForms project, reference the Module, create an instance of the form and show it:

using WfModule;
namespace WindowsFormsApplication1
{
    static class Program
    {
        /// <summary>
        /// Der Haupteinstiegspunkt für die Anwendung.
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new WfModuleForm());
        }
    }
}

Assuming your DLL is called "WfModule.Dll" and the form is called "WfModuleForm".


You should be able to create a new winforms project (an EXE, not a DLL), add the DLL library as a reference, and then instantiate and show an instance of the form defined in the DLL library.

0

精彩评论

暂无评论...
验证码 换一张
取 消