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 容器
基础教程推荐
- Azure Functions:CosmosDBTrigger 未在 Visual Studio 中触发 2022-01-01
- WPF 模态进度窗口 2022-01-01
- .NET SerialPort DataReceived 事件未触发 2022-01-01
- C# 从 List<List<int>> 中删除重 2022-01-01
- 当值可以是对象或空数组时反序列化 JSON 2022-01-01
- 如果有人提交恶意软件Nuget包怎么办? 2022-01-01
- 如何使用 .Net 检查 Active Directory 服务器是否已启动并正在运行? 2022-01-01
- 我应该在后面的代码中直接使用 Linq To SQL 还是使 2022-01-01
- Moq It.Is<>不匹配 2022-01-01
- 禁止输入少量字符,例如'<'、'&a 2022-01-01
