如何将我的新用户控件添加到工具箱或新 Winform? [英] How do I add my new User Control to the Toolbox or a new Winform?

查看:16
本文介绍了如何将我的新用户控件添加到工具箱或新 Winform?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个现有的库(不是 Winforms 应用程序),它为真正的 Windows 应用程序提供了一些 Winform.在这个库中,我想创建一个用户控件来将一些控件组合在一起.为了实现这一点,我右键单击,添加,用户控件并将一些控件拖到新的用户控件上.

I have an existing library (not a Winforms application) that supplies some Winforms to a bona-fide Windows application. Within this library, I would like to create a User Control to group some controls together. To accomplish this, I right-clicked, Add, User Control and dragged some controls onto the new User Control.

到目前为止,一切都很好.用户控件甚至具有必要的用户控件图标.但是将新的用户控件从解决方案资源管理器拖到一个新的空白 Winform 不起作用(我得到一个带有一条线的圆圈),并且将它拖到工具箱也不起作用(即使我得到一个 + 号当我将它拖到工具箱上时).

So far, so good. The User Control even has the requisite User Control icon. But dragging the new User Control from the Solution Explorer to a new blank Winform does not work (I get a circle with a line through it), and dragging it over to the Toolbox doesn't work either (even though I get a + sign when I drag it over the Toolbox).

是否有某种 XML 魔法或我缺少的其他东西来完成这项工作?

Is there some sort of XML magic or something else I'm missing to make this work?

注意:我在 Visual Studio 2008 中遇到了一些问题,我按照可以找到的解决方法设法解决了这些问题 此处.现在,我只需重新构建项目,就可以将添加到现有项目的用户控件添加到工具箱中.

Note: I had some problems with Visual Studio 2008 that I managed to fix by following the workarounds that can be found here. I am now able to get User Controls I added to my existing project into the toolbox by simply rebuilding the project.

推荐答案

假设我明白你的意思:

  1. 如果您的 UserControl 在库中,您可以使用

  1. If your UserControl is in a library you can add this to you Toolbox using

工具箱 -> 右键单击​​ -> 选择项目 -> 浏览

Toolbox -> right click -> Choose Items -> Browse

使用 UserControl 选择您的程序集.

Select your assembly with the UserControl.

如果 UserControl 是您项目的一部分,您只需要构建整个解决方案.之后,您的 UserControl 应该出现在工具箱中.

If the UserControl is part of your project you only need to build the entire solution. After that, your UserControl should appear in the toolbox.

通常,无法从解决方案资源管理器添加控件,只能从工具箱添加.

这篇关于如何将我的新用户控件添加到工具箱或新 Winform?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆