是否可以在同一个 Windows::Forms 项目中引用用户控件?
我有一个 Windows::Forms 应用程序,我想向其中添加一个自定义控件(它基本上显示一些图像并将它们与我正在绘制的一些贝塞尔曲线链接起来)。
我确信我之前已经设法让 Windows 窗体设计器在同一项目中显示自定义控件,但这次我无法让它工作。它只是说:
C++ CodeDOM 解析器错误:行:524,列:33 --- 未知类型“MyNamespace.MyCustomControl”。请确保引用了包含此类型的程序集。如果此类型是您的开发项目的一部分,请确保该项目已成功构建。
我正在创建明确提及名称空间的控件(我认为这是上次实现此功能的原因):
#include "MyCustomControl.h"
namespace MyNamespace {
public ref class MyGui: public System::Windows::Forms::Form
{
private: MyNamespace::MyCustomControl^ m_customControl;
};
}
这是不可能的还是我缺少一些特殊的解决方法?
I have a Windows::Forms application and I want to add a custom control to it (which basically displays some images and links them with some bezier curves I'm drawing).
I'm sure I've managed to get Windows Forms designer to display the custom controls in the same project before but I can't get it to work this time. It just says:
C++ CodeDOM parser error: Line: 524, Column: 33 --- Unknown type 'MyNamespace.MyCustomControl'. Please make sure that the assembly that contains this type is referenced. If this type is a part of your development project, make sure that the project has been successfully built.
I'm creating the control explicitely mentioning the namespace (which I thought was what got this worknig last time):
#include "MyCustomControl.h"
namespace MyNamespace {
public ref class MyGui: public System::Windows::Forms::Form
{
private: MyNamespace::MyCustomControl^ m_customControl;
};
}
Is this just impossible or is there some peculiar workaround I'm missing?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Windows 窗体设计器无法反映混合模式 EXE。确保使用 /clr:pure 进行编译或将任何需要设计时支持的类(例如窗体上的组件和控件)移至类库项目。
The Windows Forms Designer cannot reflect on mixed-mode EXEs. Make sure you compile with /clr:pure or move any class that require design time support (e.g. the components and controls on the form) to a class library project.