我可以使用来自同一项目中用户控件而不做一个DLL? [英] Can I use a UserControl from the same project without making a DLL?

查看:201
本文介绍了我可以使用来自同一项目中用户控件而不做一个DLL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个用户控件,并且已经能够通过将其添加到C#code的一种形式来使用它。用户控件是在同一个VS2005项目为主要形式。

I made a User Control and already was able to use it by adding it to a form in the C# code. The User Control is in the same VS2005 Project as the main form.

现在的问题是,我不能看到在GUI编辑器([设计]窗口)与此实现用户控制。我试过很多东西,但我不能给用户控件添加到真正形成德兴。

The problem is that I can't see the User Control in the gui editor ([Design] window) with this implementation. I tried many things but I wasn't able to add the user control to the real form desing.

我读了一些关于制定一个控制的lib DLL,然后这个DLL添加到工具箱中,但我不希望有一个额外的项目和一个额外的二进制文件。

I read some things about making a control lib dll and then add this dll to the toolbox but I don't want to have an additional project and an additional binary file.

我如何可以使用一个表单设计用户控件,如果双方都在同一VS项目?我认为在某种程度上,这应该是可能的吗?

How can I use a User Control in an form Design, if both are in the same VS Project? I think somehow this should be possible?

编辑1:

对不起,我有Visual Studio 2005中没有2010

Sorry I have Visual Studio 2005 not 2010

推荐答案

这当然可以使用用户控件在设计模式时,它的同一个项目的一部分。

It's certainly possible to use a UserControl in design mode when it's part of the same project.

做笔记,但是,它仅启用了AutoToolboxPopulate设置你的工具箱中显示出来。转到工具菜单,选择选项。展开Windows窗体设计器,然后单击常规。确保AutoToolboxPopulate属性设置为True。当你重建你的解决方案,你的用户控件应该出现在你的工具箱的顶部,准备添加到您的窗体。

Do note, however, that it will only show up in your toolbox if you have enabled the "AutoToolboxPopulate" setting. Go to the "Tools" menu and select "Options". Expand "Windows Forms Designer", and click on "General". Make sure that the "AutoToolboxPopulate" property is set to True. When you rebuild your solution, your UserControl should show up at the top of your toolbox, ready to add to your form.

另外,您也可以手动添加用户控件到您的工具箱。要做到这一点,在你的工具箱中单击鼠标右键,选择选择项目从上下文菜单。导航到你的控制,确保它在列表中选中,然后单击确定。

Alternatively, you can add the UserControl to your toolbox manually. To do that, right-click on your toolbox and select "Choose Items" from the context menu. Navigate to your control, ensure that it is checked in the list, and click "OK".

在该抛出一个异常(如的MacX提到的)的情况下,你仍然会被通知由设计师。该控件将仍然显示在工具箱中,你仍然可以尝试将其添加到您的窗体。

In the event that an exception is thrown (like MacX mentioned), you will still be notified by the designer. The control will still show up in the toolbox, and you'll still be able to attempt to add it to your form.

这篇关于我可以使用来自同一项目中用户控件而不做一个DLL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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