使用 UserControl 创建具有设计时支持的 ToolBox 组件
我有一个用于 Windows 窗体的用户控件。如何将其转换为组件?我想要做的是将其添加到 VS 工具箱,在设计时通过拖放将其添加到窗体中,并使用“属性”窗口更改其位置和 Dock 属性。我应该寻找什么来做到这一点?
我之前创建过类似的东西,但它是一个组件类。我可以将其添加到 VS 工具箱,通过拖放将其添加到表单,并使用“属性”窗口更改其自定义属性,但由于它是一个组件,因此显示在底部组件区域,并且没有设计时支持。
I have a UserControl for Windows Forms. How can I convert it to a component? What I want to do is, to add it to the VS toolbox, add it to form with drag and drop at design-time and change its Location and Dock properties using the Properties window. What should I look for to do this?
I've created something similar before but it was a Component class. I can add it to the VS toolbox, add it to the form with drag and drop and change its custom properties using the Properties window but since it's a component it shows on bottom component area and has no design-time support.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
UserControl
是一个组件
。您无需执行任何额外操作即可实现此目的。如果您在 VS 中创建一个新的
UserControl
,它将自动具有您正在寻找的行为:从工具箱拖到窗体上,通过“属性”面板更改其属性。此代码创建在工具箱中显示自身的功能控件,并允许更改其属性。
也许您可以将您的功能添加到此类中,然后看看它是否有效。
A
UserControl
is aComponent
. You don't have to do anything extra to make it so.If you create a new
UserControl
within VS, it will automatically have the behavior you are seeking: drag from toolbox onto form, change its properties through the Properties panel.This code creates functioning control that shows itself in the toolbox, and allows its properties to be changed.
Maybe you could add your functionality to this class and see if it works then.