是否有可能在C#类库来创建一个Windows窗体? [英] Is it possible to create a Windows Form in a C# Class Library?
问题描述
我已经建立在C#DLL类库,作为附加给它提供了一个自定义的API的应用程序。到现在为止,他们已经与数据库,计算,磁盘操作等主要包括的接口。 ?我很想知道我是否可以建立并显示一个Windows窗体,显示文本框,按钮等等,一个DLL类库里面
I've been building DLL class libraries in C#, used as add-ons to an application which provides a Custom API. Up until now they've included mostly interfacing with databases, calculations, disk operations and so forth. I'm curious to know if I can build and display a Windows Form, displaying text boxes, buttons and so forth, inside a DLL Class Library?
我试过:
using System.Windows.Forms;
不过该命名空间无法识别。
But that namespace is not recognized.
感谢您的输入。
推荐答案
我觉得效果最好对我来说是创建一个新的Windows窗体的项目,然后转到项目属性,将其更改为类库。通过这种方式,你可以右键点击的文件夹在Solution Explorer和所有的WinForms项出现就像它仍然是一个WinForms项目,但它是一个类库。这也适用于WPF应用程序。
What I find works best for me is to create a new Windows Forms project, and then go to the project properties and change it to a class library. This way, you can right click on folders in the solution explorer and all the WinForms items appear just as if it were still a WinForms project, but it's a class library. This also works with WPF applications.
这篇关于是否有可能在C#类库来创建一个Windows窗体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!