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 容器
基础教程推荐
- 如何激活MC67中的红灯 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01