Create custom winforms container(创建自定义 winforms 容器)
问题描述
我想在 winforms 中创建一个与容器控件具有相同行为的控件.我的意思是:在设计模式下,当我将控件放入其中时,它会分组,就像一个组合框.
I want to create a control in winforms with same behavior as the container controls. I mean: in design mode, when I drop controls in it, it will group then, just like a groupbox.
我正在创建的这个控件包含一些其他控件和一个 GroupBox.我所需要的只是:当一个控件在我的自定义控件上以设计模式放置时,我只需将它放在嵌套的 GroupBox 中.
This control I'm creating contains some other controls AND a GroupBox. All I need is: when a control is droped in design mode over my custom control, I'll just put it inside the nested GroupBox.
但我不知道如何让我的控件在设计模式下响应这种操作.
But I can't figure out how make my control respond to that kind of action in design mode.
推荐答案
也许 这个 是你需要的,我前段时间在 CodeProject 找到的:
Maybe this is what you need, I found it at CodeProject a time ago:
设计嵌套控件:
本文演示了如何允许一个 Control,它是另一个控件接受在设计时将控件放到它上面时间.篇幅不大,代码不多,而且这可能不是官方"或最佳方式.它确实,但是,工作,并且就我能够测试它而言是稳定的.
This article demonstrates how to allow a Control, which is a child of another Control to accept having controls dropped onto it at design time. It is not a large article, there is not much by way of code, and this may not be either the 'official' or best way to do this. It does, however, work, and is stable as far as I have been able to test it.
这篇关于创建自定义 winforms 容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:创建自定义 winforms 容器


- 输入按键事件处理程序 2022-01-01
- 如何用自己压缩一个 IEnumerable 2022-01-01
- WebMatrix WebSecurity PasswordSalt 2022-01-01
- Web Api 中的 Swagger .netcore 3.1,使用 swagger UI 设置日期时间格式 2022-01-01
- 良好实践:如何重用 .csproj 和 .sln 文件来为 CI 创建 2022-01-01
- 带有服务/守护程序应用程序的 Microsoft Graph CSharp SDK 和 OneDrive for Business - 配额方面返回 null 2022-01-01
- 在哪里可以找到使用中的C#/XML文档注释的好例子? 2022-01-01
- C#MongoDB使用Builders查找派生对象 2022-09-04
- MoreLinq maxBy vs LINQ max + where 2022-01-01
- C# 中多线程网络服务器的模式 2022-01-01