有关如何在 Windows 窗体中创建复合控件的教程?
有人知道有关此主题的任何教程吗?
我搜索了网络,但我看到的主要是 ASP.NET 控件,而不是 winforms。
Anyone knows any tutorials with this topic?
I searched the net but I see mostly asp.net controls, not winforms.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试 CodeProject 上的 WinForm 自定义控件 部分对于许多源代码示例。
这看起来非常以“操作方法”为导向:
编写您自己的条形图 Winforms 用户控件
Try the WinForm Custom Controls section on CodeProject for many source code samples.
This one looks pretty 'how-to' oriented:
Write Your Own Bar Chart Winforms User Control
如果您搜索“UserControl”,您可能会获得更多结果,因为您可能希望从中派生自定义/复合控件。
通常,我会在 UserControl 上放置多个控件,并仅公开程序员使用它所需的方法和属性。我制作的此类控件的一个很好的例子是数字时钟,其中每个数字本身就是一个自定义控件(实际上是一个图片框,加上一些控制逻辑)。然后,我可以将该控件拖放到任何需要的地方。
这是一个您可能会觉得方便的教程。
顺便说一句,当我进行谷歌搜索时,我使用了以下内容:
忽略了您提到的许多 ASP 教程。看来 ASP 程序员确实大量使用这些用户控件!
You might get more results if you search for 'UserControl' as you'll likely want to derive your custom/composite controls from that.
Typically, I'll place several controls on a UserControl, and expose only the methods and properties I need for the programmer to use it. A good example of such a control I made was a digital clock, where each digit was itself a custom control (which was actually a picturebox, coupled with some controlling logic). Then, I was able to drag n drop this control wherever I needed it.
Here's one tutorial you might find handy.
As an aside, when I did my google search, I used the following:
which ignored a lot of the ASP tutorials you were mentioning. It does seem that ASP programmers use a lot of these user controls!