C# - 带有面板的自定义控件,如何让 IDE 将项目添加到面板?
我有一个自定义控件,其中包含一个面板,我希望能够将控件放在 VS IDE 中,并使这些控件实际上成为该面板的子项(面板是我的自定义控件的子项),而不拥有它们添加到我的自定义控件所在的表单中。
基本上,当您将控件放在未包含在自定义控件中的面板上时会发生什么。
我尝试用谷歌搜索它,但似乎无法得出任何好的结果,任何帮助将不胜感激:)
I have a custom control which contains a panel, of which I want to be able to drop controls on in the VS IDE and have those controls actually be a child of the panel (which is a child of my custom control) and not have them added to the form my custom control is on.
Basically what happens when you drop controls on a panel not contained in a custom control.
I've tried to google it, but can't seem to come up with any good results, any help would be appreciated :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您正在谈论 WinForms,我想如果您将自定义控件更改为从 ContainerControl 而不是
UserControl
。如果是 WebForms,可能值得一看 ContainerControlDesigner ,但我对此了解不多。
Assuming that you're talking about WinForms I think you'll get what you want if you change your custom control to inherit from ContainerControl rather than
UserControl
.If it's WebForms it might be worth looking at ContainerControlDesigner, but I don't know much about that.